[英]Maven - Remove Dependency from a Jar
我在應用程序的pom.xml中將Jar文件用作依賴項。 不幸的是,此jar中有pom.xml和pom.properties文件,而我的Maven應用程序正嘗試下載這些文件中存在的其他工件。
您能否讓我知道如何排除這些文件或停止尋找其他工件。
示例:我正在添加abc.jar
<dependency>
<groupId>xyz</groupId>
<artifactId>abc</artifactId>
<version>1</version>
</dependency>
現在,“ abc.jar”具有自己的pom.xml,其中存在工件,如下所示
<parent>
<groupId>DEFGH</groupId>
<artifactId>NewArtifact</artifactId>
<version>1</version>
</parent>
注意:我嘗試在“ dependency”標簽下使用“ exclusions”,但沒有用。
看一下這個片段:
<dependency>
<groupId>org.squirrelframework</groupId>
<artifactId>squirrel-foundation</artifactId>
<version>0.3.2</version>
<!-- explicitly disable squirrel-foundation dependency because it messes up project logging backend configuration -->
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
在此代碼段中,我明確刪除了與squirrel-foundation
軟件包一起提供的對log4j和slf4j-log4j12的依賴關系。
如果可以控制從屬jar的構建過程,則可以使用此配方將jar中的pom.xml和pom.properties完全排除在外,但是我懷疑這是一個好的解決方案。 以其他方式處理額外的依賴關系會更正確/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.