簡體   English   中英

如何防止Maven復制EAR文件中的jar?

[英]How to prevent maven from duplicating jars in an EAR file?

我有一個由maven構建的EAR文件,目前有一個我想放入EAR \\ lib的Commons項目,所以我使用了帶有'bundleDir'標簽的maven-ear-plugin,它工作正常,僅現在我的commons.jar出現在lib文件夾和EAR根目錄中。 我如何告訴它僅將其放在lib文件夾中?

我的pom:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
                <outputDirectory>../../outputs/java</outputDirectory>
                <version>5</version>
                <modules>
                    <jarModule>
                        <groupId>com.sample.common</groupId>
                        <artifactId>common</artifactId>
                        <includeInApplicationXml>
                            true
                        </includeInApplicationXml>
                        <bundleDir>/lib</bundleDir>
                    </jarModule>
                    ...
                </modules>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>ear</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

這是依賴項定義:

<dependency>
        <groupId>com.sample.common</groupId>
        <artifactId>common</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>

如果您的jar文件不是ejb,則可以簡單地將其置於ear依賴項,而無需將其定義到maven-ear-plugin中。 否則,請嘗試在依賴項列表中設置提供給jar的作用域。 這可能會有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM