Maven 不解析父 POM 文件
Maven doesn't resolve parent POM file
我有一个 父 POM 文件 和四个 子 POM 文件。子模块无法解析 relativePath
../pom.xml
.
错误:
Error
项目结构:
Project structure
man clean install -X:
mvn clean install -X
ParentPom:
<?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 https://maven.apache.org/xsd/maven 4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>filler</groupId>
<artifactId>filler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>filler</name>
<packaging>pom</packaging>
<modules>
<module>account-service</module>
<module>lottery-ticket-service</module>
<module>lottery-service</module>
<module>service-registry</module>
</modules>
ChildPom/lottery-ticket-service:
<parent>
<groupId>filler</groupId>
<artifactId>filler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>lottery-ticket-service</artifactId
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>13</java.version>
</properties>
ChildPom/lottery-service:
<parent>
<groupId>filler</groupId>
<artifactId>filler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>lottery-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>13</java.version>
</properties>
ChildPom/service-registry:
<parent>
<groupId>filler</groupId>
<artifactId>filler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>service-registry</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>13</java.version>
</properties>
ChildPom/account-service:
<parent>
<groupId>filler</groupId>
<artifactId>filler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>account-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>13</java.version>
</properties>
从子目录中删除此标签 pom.xml 默认情况下它将在父目录
中搜索
<relativePath>../pom.xml</relativePath>
看来您必须将父项目的名称添加到路由中:
<relativePath> ../parentclass/pom.xml </relativePath>
我有一个 父 POM 文件 和四个 子 POM 文件。子模块无法解析 relativePath
../pom.xml
.
错误: Error
项目结构: Project structure
man clean install -X: mvn clean install -X
ParentPom:
<?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 https://maven.apache.org/xsd/maven 4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>filler</groupId>
<artifactId>filler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>filler</name>
<packaging>pom</packaging>
<modules>
<module>account-service</module>
<module>lottery-ticket-service</module>
<module>lottery-service</module>
<module>service-registry</module>
</modules>
ChildPom/lottery-ticket-service:
<parent>
<groupId>filler</groupId>
<artifactId>filler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>lottery-ticket-service</artifactId
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>13</java.version>
</properties>
ChildPom/lottery-service:
<parent>
<groupId>filler</groupId>
<artifactId>filler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>lottery-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>13</java.version>
</properties>
ChildPom/service-registry:
<parent>
<groupId>filler</groupId>
<artifactId>filler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>service-registry</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>13</java.version>
</properties>
ChildPom/account-service:
<parent>
<groupId>filler</groupId>
<artifactId>filler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>account-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>13</java.version>
</properties>
从子目录中删除此标签 pom.xml 默认情况下它将在父目录
中搜索<relativePath>../pom.xml</relativePath>
看来您必须将父项目的名称添加到路由中:
<relativePath> ../parentclass/pom.xml </relativePath>