gpt4 book ai didi

java - Maven pom.xml 依赖项 - 调整

转载 作者:行者123 更新时间:2023-12-02 02:07:58 36 4
gpt4 key购买 nike

我开始使用 Maven 构建工具来构建 Java 项目。我已将 maven 添加到系统路径,并且我有 3.5.3 版本。我必须在 Eclipse 中的 pom.xml 文件中红色提示该文件中的某些内容是错误的。我试图找到一些资源,并尝试更改我使用的源中的版本,然后构建,但它不起作用我有这样的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。

最佳答案

将您的 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

这里的版本是您想要的 Artifact 版本,而不是您的 Maven 版本(3.5.3)

关于java - Maven pom.xml 依赖项 - 调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50464218/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com