运行“ MVN全新安装”时如何解决警告消息

我正在使用jdk 8和maven版本3.3.9创建具有最新版本1.5.6.RELEASE的spring boot应用程序。我在运行时收到以下警告消息mvn

clean install

[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null]

[WARNING]

[WARNING] Some problems were encountered while building the effective model for com.XXXX:foo:jar:1.0.0

[WARNING] 'parent.relativePath' of POM com.XXX:foo:1.0.0 (/home/user/parent/foo/pom.xml) points at com.XXX:parent instead of org.springframework.boot:spring-boot-starter-parent, please verify your project structure @ line 12, column 13

[WARNING]

[WARNING] Some problems were encountered while building the effective model for com.XXX:bar:jar:1.0.0

[WARNING] 'parent.relativePath' of POM com.XXX:bar:1.0.0 (/home/user/parent/bar/pom.xml) points at com.XXX:parent instead of org.springframework.boot:spring-boot-starter-parent, please verify your project structure @ line 12, column 13

[WARNING]

[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.

[WARNING]

[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

[WARNING]

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Build Order:

我的项目是多模块构建。目录结构为:

xxx-project

|-- pom.xml

|-- foo

| |-- pom.xml

|-- bar

| |-- pom.xml

我的foo / 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>com.xxx</groupId>

<artifactId>foo</artifactId>

<version>1.0.0</version>

<packaging>jar</packaging>

<name>foo</name>

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>1.5.6.RELEASE</version>

</parent>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<start-class>com.xxx.foo.App</start-class>

<java.version>1.8</java.version>

<lombok.version>1.16.18</lombok.version>

<log4jdbc.log4j2.version>1.16</log4jdbc.log4j2.version>

<rest.assured.version>3.0.3</rest.assured.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-jdbc</artifactId>

</dependency>

<dependency>

<groupId>com.h2database</groupId>

<artifactId>h2</artifactId>

</dependency>

<dependency>

<groupId>org.projectlombok</groupId>

<artifactId>lombok</artifactId>

<version>${lombok.version}</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>org.bgee.log4jdbc-log4j2</groupId>

<artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>

<version>${log4jdbc.log4j2.version}</version>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-test</artifactId>

<scope>test</scope>

</dependency>

<dependency>

<groupId>io.rest-assured</groupId>

<artifactId>rest-assured</artifactId>

<version>${rest.assured.version}</version>

<scope>test</scope>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

<dependencies>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>springloaded</artifactId>

<version>${spring-loaded.version}</version>

</dependency>

</dependencies>

</plugin>

</plugins>

</build>

</project>

上面的pom.xml是使用github的maven原型spring-boot-blank项目生成的。

父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>com.XXX</groupId>

<artifactId>parent</artifactId>

<version>1.0.0</version>

<packaging>pom</packaging>

<name>parent</name>

<modules>

<module>foo</module>

<module>bar</module>

</modules>

</project>

编译我的源代码时如何解决此警告消息?

请提供您的输入。

回答:

发生问题是因为默认情况下,Maven假定在包含模块pom的父文件夹中找到了父pom。但是,在您的项目中情况似乎并非如此:父pom为

org.springframework.boot:spring-boot-starter-parent:1.5.6.RELEASE, 而pom

com.xxx:parent:1.0.0 在父文件夹仅用作模块的聚合器。

要解决此问题,您需要像这样在模块poms中的父声明中取消设置相对路径:

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>1.5.6.RELEASE</version>

<relativePath/>

</parent>

以上是 运行“ MVN全新安装”时如何解决警告消息 的全部内容, 来源链接: utcz.com/qa/419015.html

回到顶部