在pom.xml中找不到工件问题

时间:2013-01-30 08:59:34

标签: java maven pom.xml

我是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]

请帮帮我。

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:2)

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