问题描述
要使用Maven构建Java EE应用程序,可以使用以下配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<modules>
<webModule>
[..]
</webModule>
<ejbModule>
[..]
</ejbModule>
<jarModule>
[..]
</jarModule>
</modules>
</configuration>
</plugin>
我了解到,Web模块与其他模块的包装方式不同,例如,位于耳朵的根部并将其自身的依存关系打包为WEB-INF/lib
。
但是jar和ejb模块呢?它们彼此之间有何不同?
将jar定义为普通依赖项和/或将其定义为jarModule
或earModule
有什么区别?
准确地说,以下设置之间有什么区别
1。定义为ejbModule的ejb模块
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<modules>
<webModule>
[..]
</webModule>
<ejbModule>
<groupId>org.example</groupId>
<artifactId>helloworld-model</artifactId>
<version>1.0-SNAPSHOT</version>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
</dependencies>
2。定义为依赖项的ejb模块
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<modules>
<webModule>
[..]
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<depdendency>
<groupId>org.example</groupId>
<artifactId>helloworld-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
3。 ejb / jar定义为jarModule
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<modules>
<webModule>
[..]
</webModule>
<jarModule>
<groupId>org.example</groupId>
<artifactId>helloworld-model</artifactId>
<version>1.0-SNAPSHOT</version>
</jarModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
4。 ejb / jar定义为依赖项
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<modules>
<webModule>
[..]
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<depdendency>
<groupId>org.example</groupId>
<artifactId>helloworld-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
解决方法
要回答部分问题:
EJB工件转到EAR的主目录,而JAR工件转到lib
目录。