Maven无法解析父POM文件

问题描述 投票:0回答:2

我有一个父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>
java maven pom.xml relative-path parent-pom
2个回答
0
投票

尝试替换

<relativePath>../pom.xml</relativePath> with 
<relativePath>../</relativePath>

0
投票

似乎您必须在路径中添加父项目的名称:

../ parent / pom.xml

© www.soinside.com 2019 - 2024. All rights reserved.