英文:
Maven EAR Plugin Modules
问题
构建一个使用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模块与其他模块的打包方式不同,例如,位于ear的根目录,并将其自身的依赖项打包到WEB-INF/lib
目录下。
那么Jar模块和EJB模块有什么不同呢?它们彼此之间有什么区别?
以及将Jar定义为普通依赖项和/或将其定义为jarModule
或ejbModule
之间有什么区别?
更准确地说,以下设置之间有什么区别:
1. 将EJB模块定义为ejbModule
<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>
<dependency>
<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>
<dependency>
<groupId>org.example</groupId>
<artifactId>helloworld-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
英文:
To build a Java EE application with Maven, one can use the following configuration:
<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>
I understand that the web module is packaged differently from other modules, that is, for example, being located at the root of the ear and having packed it's own dependencies to WEB-INF/lib
.
But what about jar and ejb modules? How are they different from each other?
And what is the difference of defining a jar as a normal dependency and/or defining it as a jarModule
or ejbModule
?
Beeing more precise, what is the difference between the following setups:
1. ejb module defined as ejbModule
<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 module defined as dependency
<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 defined as 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 defined as dependency
<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>
答案1
得分: 1
回答你问题的一部分:
EJB(Enterprise JavaBeans)的构件放在EAR(Enterprise Archive)的主目录中,而JAR(Java Archive)的构件放在lib
目录中。
英文:
To answer a part of your question:
EJB artifacts go to the main directory of the EAR, while JAR artifacts go to the lib
dir.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论