我有一个父POM文件和四个子POM文件。子模块无法解析relativePath
../pom.xml
。
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 /彩票门票服务:
<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 /彩票服务:
<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 /帐户服务:
<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>
尝试替换
<relativePath>../pom.xml</relativePath> with
<relativePath>../</relativePath>
似乎您必须在路径中添加父项目的名称:
../ parent / pom.xml