[英]Maven creation of a WAR and an EAR containing that WAR as one module using classifier?
我了解這聽起來可能是錯誤的事情,但是我試圖做的是安裝一個Maven POM(模塊),該模塊在安裝時將打包為WAR,但此外,還打包為包含單個WAR的EAR。
需要說明的是:我希望將項目中的每個現有WAR打包在其自己的 EAR中。
我渴望得到支持的原因是因為我正在重新考慮打包已發布的WAR的方式,以便將每個WAR包含在EAR中(但仍會生成獨立的WAR工件以簡化開發工作)。 我不希望創建一個依賴WAR的新模塊並將其打包到EAR中,因為我有很多WAR。
目前,對於我現有的WAR模塊之一,我正在嘗試使用分類器 , 但沒有成功:
<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">
<parent>
...
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>se-index-webapp</artifactId>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
...
</configuration>
</plugin>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<finalName>search-index.ear</finalName>
<classifier>ear</classifier>
<unpackTypes>war</unpackTypes>
<modules>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<uri>search-index.war</uri>
<bundleFileName>search-index.war</bundleFileName>
<contextRoot>/SearchIndex</contextRoot>
</webModule>
</modules>
</configuration>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
...
</dependencies>
</project>
我得到錯誤:
Artifact[war:myproject:se-index-webapp] is not a dependency of the project
我想做的事可能嗎?
您需要更改的第一件事是基於Maven約定,以擁有一個單獨的EAR模塊,該模塊具有以下結構:
+-- root (pom.xml)
+--- mod-ear (pom.xml) packaging: ear
+--- mod-war (pom.xml) packaging: war
比您可以通過以下方式非常簡單地定義對mod-war模塊的依賴關系:
<dependencies>
<dependency>
<groupId>..</groupId>
<artifactId>..</artifactId>
<version>..</version>
</dependency>
...
</dependencies>
這種方法的優點是,您已將屬於耳朵的信息和屬於耳朵模塊的信息分開了。
結果是您可以在根級別執行mvn清潔程序包,也可以執行mvn安裝/部署,從而將war和ear部署到存儲庫中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.