Java maven,ear包将依赖项放在ear和web模块下
我有一个ear模块,由以下部分组成: 耳朵 ejb 网 我使用maven来管理包;每个模块都有自己的pom.xml 现在,让我们假设ear模块的pom.xml是这样的:Java maven,ear包将依赖项放在ear和web模块下,java,maven,jakarta-ee,java-ee-8,Java,Maven,Jakarta Ee,Java Ee 8,我有一个ear模块,由以下部分组成: 耳朵 ejb 网 我使用maven来管理包;每个模块都有自己的pom.xml 现在,让我们假设ear模块的pom.xml是这样的: <dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>myproject-ejb</artifac
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>myproject-ejb</artifactId>
<type>ejb</type>
</dependency>
<!-- Depend on the EJB module and WAR so that we can package them -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>myproject-web</artifactId>
<type>war</type>
</dependency>
<build>
<finalName>${project.parent.artifactId}</finalName>
<plugins>
<!--EAR plugin: format of output file -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>${version.ear.plugin}</version>
<configuration>
<!-- Tell Maven we are using Jakarta EE -->
<version>8</version>
<!-- Use Jakarta EE ear libraries as needed. Jakarta EE ear libraries
are in easy way to package any libraries needed in the ear, and automatically
have any modules (EJB-JARs and WARs) use them -->
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<!-- Default context root of the web app is /customers-web.
If a custom context root is needed, uncomment the following snippet to
register our War as a web module and set the contextRoot property -->
<!--
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>customers-web</artifactId>
<contextRoot>/customers</contextRoot>
</webModule>
-->
</modules>
<outputFileNameMapping>@{artifactId}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
</configuration>
</plugin>
<!-- The WildFly plug-in deploys your ear to a local JBoss EAP container.
Due to Maven's lack of intelligence with EARs we need to configure
the WildFly Maven plug-in to skip deployment for all modules. We then enable
it specifically in the ear module. -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
${project.groupId}
myproject ejb
ejb
${project.groupId}
myproject网站
战争
${project.parent.artifactId}
org.apache.maven.plugins
maven耳朵插件
${version.ear.plugin}
8.
解放党
@{artifactId}@{dashClassifier?}@{extension}@
org.wildfly.plugins
wildfly maven插件
假的
。。这是根目录上的pom.xml
<dependency>
<groupId>org.burp</groupId>
<artifactId>some-lib</artifactId>
<scope>compile</scope>
</dependency>
org.burp
一些图书馆
编译
编译ear时,可以看到some-lib.jar位于{root}/lib和myprojectweb/web-INF/lib上
如何将所有依赖项仅放在{root}/lib上您可以在war模块中覆盖依赖项的范围,例如:
<dependency>
<groupId>org.burp</groupId>
<artifactId>some-lib</artifactId>
<scope>provided</scope>
</dependency>
org.burp
一些图书馆
假如
我已经使用过这个解决方案,老实说,我认为它并不那么出色。也许没有替代品。你希望有什么样的替代品?嗯,比如ear插件上的一种属性。。。但如果我不知道它的存在,我只能猜测到目前为止