0

我是 J2EE 新手。我在 pom.xml 中遇到问题。我pom.xml的是这样的:

<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>
<artifactId>atom</artifactId>
<packaging>pom</packaging>
<name>ATOM</name>
<!-- Shared version number properties passed down to modules -->
<properties>
    <org.springframework.version>3.1.2.RELEASE</org.springframework.version>
    <slf4j.version>1.5.11</slf4j.version>
    <log4j.version>1.2.16</log4j.version>
    <junit.version>4.8.2</junit.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.build.resourceEncoding>${project.build.sourceEncoding}</project.build.resourceEncoding>
</properties>
<modules>
    <module>atom-domain</module>
    <module>atom-presentation</module>
</modules>
<dependencies>
    <!-- Logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>${log4j.version}</version>
    </dependency>
</dependencies>

<description>New ATOM Project</description>
<parent>
    <groupId>com.bah</groupId>
    <artifactId>atom</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>

我的标签有错误。<parent>我不知道要修复它。我的错误报告是这样的:

 The project com.bah:atom:0.0.1-SNAPSHOT (D:\eclipse_code\J2EE_workspace\atom\pom.xml) has 1 error
 [ERROR]   Non-resolvable parent POM: Could not find artifact com.bah:atom:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 45, column 10 -> [Help 2]

请帮助我。

4

2 回答 2

3

<relativePath>向父级添加参数<parent>

<parent>
    <groupId>com.bah</groupId>
    <artifactId>atom</artifactId>
    <version>0.0.1-SNAPSHOT</version>
     <relativePath>../pathtopom/my-parent-pom.xml</relativePath>
</parent>  

之前安装父pom。
执行
mvn clean install -f my-parent-pom.xml

于 2013-01-30T09:05:00.233 回答
2

你确定你需要parentmodules标签吗?通常不需要任何这个标签,除非你想要一个 pom 文件一次构建所有模块('maven reactor' http://maven.apache.org/guides/mini/guide-multiple-modules.html)使用dependency和丢弃父子结构。

于 2013-01-30T09:19:15.897 回答