我试图使用maven插件创建一个ear文件,但它在耳朵项目pom上失败了。我已经盯着这几个小时了,无法解决这个问题。我使用eclipse所以我的所有项目,包括父项都在同一个目录中。
我的父pom.xml:
<?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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-parent</artifactId>
<packaging>pom</packaging>
<version>${traintrack-version}</version>
<name>traintrack-parent</name>
<url>http://maven.apache.org</url>
<properties>
<traintrack-version>0.0.1-SNAPSHOT</traintrack-version>
</properties>
<modules>
<module>../traintrack-core</module>
<module>../traintrack-web</module>
<module>../traintrack-services-authentication</module>
<module>../traintrack-ear</module>
</modules>
</project>
我的耳朵pom.xml
<?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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-parent</artifactId>
<version>${traintrack-version}</version>
<relativePath>../traintrack-parent/pom.xml</relativePath>
</parent>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-ear</artifactId>
<name>traintrack-ear</name>
<packaging>ear</packaging>
<version>${traintrack-version}</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<generateApplicationXml>true</generateApplicationXml>
<displayName>traintrack-ear</displayName>
<modules>
<jarModule>
<groupId>com.tracktrack</groupId>
<artifactId>traintrack-core</artifactId>
<bundleDir>lib</bundleDir>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
<webModule>
<groupId>com.tracktrack</groupId>
<artifactId>traintrack-web</artifactId>
<contextRoot>/TrainTrack</contextRoot>
</webModule>
<jarModule>
<groupId>com.tracktrack</groupId>
<artifactId>traintrack-services-authentication</artifactId>
<bundleDir>lib</bundleDir>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
</modules>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-web</artifactId>
<version>${traintrack-version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-core</artifactId>
<version>${traintrack-version}</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-services-authentication</artifactId>
<version>${traintrack-version}</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
我的模块pom.xmls如下所示
<parent>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-parent</artifactId>
<relativePath>../traintrack-parent/pom.xml</relativePath>
<version>${traintrack-version}</version>
</parent>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-core</artifactId>
<version>${traintrack-version}</version>
<packaging>jar</packaging>
我收到以下错误
Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.10:generate-application-xml (default-generate-application-xml) on project traintrack-ear: Artifact[jar:com.tracktrack:traintrack-core] is not a dependency of the project.
我一直在玩依赖项,我发现当我删除ear pom.xml中的依赖项部分时,我得到了同样的错误。它始终是耳朵中列出的第一个抛出错误的模块,而且所有模块都会这样做。
在某个地方可能是一个愚蠢的错误,但我无法发现它。任何帮助表示赞赏。
答案 0 :(得分:3)
maven-ear-plugin
的配置出错。 groupId
的{{1}}应为traintrack-core
,而不是com.traintrack
所以,改为:
com.tracktrack
使用此:
<jarModule>
<groupId>com.tracktrack</groupId>
<artifactId>traintrack-core</artifactId>
<bundleDir>lib</bundleDir>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
修改强>
<jarModule>
<groupId>com.traintrack</groupId>
<artifactId>traintrack-core</artifactId>
<bundleDir>lib</bundleDir>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
和traintrack-web
也应该这样做。
一些与问题无关的提示:
与问题无关的一些提示直接:
compile
。您可以从子模块中删除groupId
(例如groupId
)并继续运行=)traintrack-core
与所有模块/项目相同时,您可以使用${project.groupId}
来避免像您这样的错误,以及依赖关系groupId
是相同的项目E.g:
groupId