我尝试使用EJB和WAR创建EAR项目,但是遇到了一些问题。 我从Java EE 6 EAR原型创建了主要的项目:
<dependency>
<groupId>org.codehaus.mojo.archetypes</groupId>
<artifactId>ear-javaee6</artifactId>
<version>1.5</version>
</dependency>
接下来我使用Java EE 6 EJB JAR Archetype创建了EJB模块:
<dependency>
<groupId>org.codehaus.mojo.archetypes</groupId>
<artifactId>ejb-javaee6</artifactId>
<version>1.5</version>
</dependency>
然后我从Javax Faces WAR Archetype创建了第二个模块:
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-war-archetype</artifactId>
<version>2.2</version>
</dependency>
然后我在主要的pom.xml文件中添加了依赖:
<!-- Define the versions of your ear components here -->
<dependencies>
<dependency>
<groupId>QCforCC-main</groupId>
<artifactId>QCforCC-ejb</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>QCforCC-main</groupId>
<artifactId>QCforCC-war</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
然后我尝试使用maven clean和install构建项目,但是出现了错误:
[ERROR] The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='QCforCC-main:QCforCC-war:1.0-SNAPSHOT'}' and 'Vertex{label='QCforCC-main:QCforCC-ejb:1.0-SNAPSHOT'}' introduces to cycle in the graph QCforCC-main:QCforCC-ejb:1.0-SNAPSHOT --> QCforCC-main:QCforCC-war:1.0-SNAPSHOT --> QCforCC-main:QCforCC-ejb:1.0-SNAPSHOT - [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectCycleException
Process finished with exit code 1
在 EAR 中,pom.xml
文件中我有以下内容:
<modules>
<module>QCforCC-ejb</module>
<module>QCforCC-war</module>
</modules>
<packaging>pom</packaging>
但是如果我将<packaging>pom</packaging>
改为<packaging>ear</packaging>
,
IDEA会在弹出窗口中显示错误:
Some problems were encountered while processing the POMs:
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-ear-plugin @ line 41, column 21
[ERROR] 'packaging' with value 'ear' is invalid. Aggregator projects require 'pom' as packaging. @ line 12, column 16
<modules>
的元素中。 - Tom Chamberlain