Maven EAR插件模块

问题描述

要使用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定义为普通依赖项和/或将其定义为jarModuleearModule有什么区别?

准确地说,以下设置之间有什么区别

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目录。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...