如何在运行“mvn全新安装”时修复警告消息
2022-09-03 18:33:54
我正在使用jdk 8和maven版本3.3.9来创建具有最新版本1.5.6.RELEASE的弹簧启动应用程序。我在运行时收到以下警告消息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>
如何在编译源代码时解决此警告消息?
请提供您的意见。