Maven pom.xml зависимости - настройка - PullRequest
0 голосов
/ 22 мая 2018

Я начинаю использовать инструмент сборки Maven для проектов Java.Я добавил maven в системный путь и у меня есть версия 3.5.3.Я должен дать красные подсказки в файле pom.xml в Eclipse, что что-то в этом файле не так.Я попытался найти некоторые ресурсы, и я попытался изменить версии, как в исходном тексте, который я использовал, и затем построить, но это не сработало. У меня есть такой файл pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>authorization</groupId>
<artifactId>auth</artifactId>
<version>4.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>auth</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.5.3</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Ошибки вывода сборки Maven:

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for authorization:auth:4.1.0-SNAPSHOT: 
Failure to find org.springframework.boot:spring-boot-starter- 
parent:pom:3.5.3 in https://repo.maven.apache.org/maven2 was cached in the 
local repository, resolution will not be reattempted until the update 
interval of central has elapsed or updates are forced and 
'parent.relativePath' points at no local POM @ line 14, column 10
@ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project authorization:auth:4.1.0-SNAPSHOT 
(C:\Users\lukas\workspace\auth\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for authorization:auth:4.1.0-SNAPSHOT: 
Failure to find org.springframework.boot:spring-boot-starter- 
parent:pom:3.5.3 in https://repo.maven.apache.org/maven2 was cached in the 
local repository, resolution will not be reattempted until the update 
interval of central has elapsed or updates are forced and 
'parent.relativePath' points at no local POM @ line 14, column 10 -> [Help 
2]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e 
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] 
http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

Я проверил команду mvn -version , и это 3.5.3.Вопрос, на мой взгляд, это заявление SNAPSHOT.а как все правильно настроить?Я использовал Gradle, и теперь я делаю Maven.

Ответы [ 2 ]

0 голосов
/ 22 мая 2018

Вы можете использовать этот файл pom.xml, и у вас не возникнет никаких проблем, так как я попробовал и протестировал его.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>authorization</groupId>
    <artifactId>auth</artifactId>
    <version>4.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
0 голосов
/ 22 мая 2018

Измените ваш pom на:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
    </parent>

Если вы проверите папку репозитория maven здесь https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/, вы увидите, что последняя версия - 2.0.2.RELEASE

версия - это версия требуемого артефакта, а не версия Maven (3.5.3)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...