[英]Maven Multi Module EAR - Not adding child modules
我有一個基於 wildfly-jakartaee8-with-tools 原型的 Maven 多模塊項目 (Jakarta EE 8),部署在 Wildly 26 上並使用 maven-ear-plugin (3.2.0)
這是項目結構
-WebApp.ear
-Web-entities.jar
-Web-ejb.jar
-Web-web.war
-Web-mobile.war
-Web-api.war
這是Web-ear pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.webapp</groupId>
<artifactId>WebApp</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>Web-ear</artifactId>
<packaging>ear</packaging>
<name>Web - ear</name>
<description>This is the EAR POM file</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Web-entities</artifactId>
<type>ejb</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Web-ejb</artifactId>
<type>ejb</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Web-web</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Web-mobile</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Web-api</artifactId>
<type>war</type>
</dependency>
</dependencies>
<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>
<displayName>Web-ear</displayName>
<generateApplicationXml>true</generateApplicationXml>
<initializeInOrder>true</initializeInOrder>
<!-- 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>
<unpackTypes>war</unpackTypes>
<modules>
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>Web-entities</artifactId>
<bundleFileName>Web-entities.jar</bundleFileName>
</ejbModule>
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>Web-ejb</artifactId>
<bundleFileName>Web-ejb.jar</bundleFileName>
</ejbModule>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>Web-web</artifactId>
<contextRoot>/webapp</contextRoot>
<bundleFileName>Web-web.war</bundleFileName>
</webModule>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>Web-mobile</artifactId>
<contextRoot>/mobile</contextRoot>
<bundleFileName>Web-mobile.war</bundleFileName>
</webModule>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>Web-api</artifactId>
<contextRoot>/api</contextRoot>
<bundleFileName>Web-api.war</bundleFileName>
</webModule>
</modules>
</configuration>
</plugin>
<!-- The WildFly plug-in deploys your ear to a local WildFly / 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>
但是當我構建生成的 application.xml 不包括任何子模塊。
如果我將generateApplicationXml
設置為 false,然后使用指定的模塊手動創建 application.xml,它仍然不會在 output EAR 中添加子模塊。 但是如果我在 ear pom 中的模塊依賴項上設置<scope>compile</scope>
它確實包括它們 - 但這對我來說似乎是錯誤的,因為我看到的所有示例都使用<scope>provided</scope>
?
我可以看到 Maven 正在正確構建每個子模塊,它們存在於子模塊的 /target output 文件夾中,但它只是沒有將它們添加到 EAR output,我只是得到一個帶有元信息的空 EAR
我發現這個問題的原因是在項目父pom.xml
依賴項被標記為<scope>provided</scope>
從而阻止子模塊被打包,刪除這個修復了問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.