多模块maven构建:来自父模块和来自模块的不同结果
我正在将一个应用程序从ant build迁移到maven 3 build。 此应用程序由以下部分组成:多模块maven构建:来自父模块和来自模块的不同结果,maven,maven-3,Maven,Maven 3,我正在将一个应用程序从ant build迁移到maven 3 build。 此应用程序由以下部分组成: 指定要生成的所有模块的父项目 使用jaxb生成类并使用它们构建jar的项目 构建ejb项目的项目 3个构建war模块的项目 1.建立ear的项目 以下是我父母pom的摘录: <groupId>com.test</groupId> <artifactId>P</artifactId> <packaging>pom</packa
- 指定要生成的所有模块的父项目
- 使用jaxb生成类并使用它们构建jar的项目
- 构建ejb项目的项目
- 3个构建war模块的项目
- 1.建立ear的项目
<groupId>com.test</groupId>
<artifactId>P</artifactId>
<packaging>pom</packaging>
<version>04.01.00</version>
<modules>
<module>../PValidationJaxb</module> <-- jar
<module>../PValidation</module> <-- ejb
<module>../PImport</module> <-- war
<module>../PTerminal</module> <-- war
<module>../PWebService</module> <-- war
<module>../PEAR</module> <-- ear
</modules>
<parent>
<groupId>com.test</groupId>
<artifactId>P</artifactId>
<version>04.01.00</version>
</parent>
<artifactId>P-webservice</artifactId>
<packaging>war</packaging>
<properties>
<jersey.version>1.14</jersey.version>
</properties>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.rte.etso</groupId>
<artifactId>etso-validation</artifactId>
<version>${project.version}</version>
<type>ejb-client</type>
</dependency>
...
[other libs]
...
<dependency>
<groupId>org.mockejb</groupId>
<artifactId>mockejb</artifactId>
<version>0.6-beta2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>cglib</groupId>
<artifactId>cglib-full</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2.2</version>
<scope>test</scope>
</dependency>
</dependencies>
com.test
P
聚甲醛
04.01.00
../PValidationJaxb第一件重要的事情是,您应该创建适合模块结构的项目结构,这意味着具有以下文件夹结构:
+-- parent
+-- PValidationJaxb
+-- PValidation
+-- PImport
+-- PTerminal
+-- PWebService
+-- PEAR
这意味着在父文件夹中有一个pom.xml,其中包含模块定义。
如果遵循上述建议,您可以将模块列表简化为以下内容:
<modules>
<module>PValidationJaxb</module> <-- jar
<module>PValidation</module> <-- ejb
<module>PImport</module> <-- war
<module>PTerminal</module> <-- war
<module>PWebService</module> <-- war
<module>PEAR</module> <-- ear
</modules>
单元测试的问题听起来像是缺少依赖项等。但这里的问题是,您如何尝试运行单元测试,以及是否配置了maven surefire插件?或者你有集成测试吗?这只是一个猜测,因为我在您的POM中没有看到Maven插件的任何配置。我的配置确实有问题,我编辑了问题的结尾,解释了问题的内容。谢谢
+-- parent
+-- PValidationJaxb
+-- PValidation
+-- PImport
+-- PTerminal
+-- PWebService
+-- PEAR
<modules>
<module>PValidationJaxb</module> <-- jar
<module>PValidation</module> <-- ejb
<module>PImport</module> <-- war
<module>PTerminal</module> <-- war
<module>PWebService</module> <-- war
<module>PEAR</module> <-- ear
</modules>
mvn -pl module clean package