简体   繁体   English

Maven从依赖项中删除资源

[英]Maven remove resource from dependency

I have a jgroups dependency which has a log4j2.xml in its JAR which is getting picked up by log4j instead of my config file. 我有一个jgroups依赖log4j2.xml ,它的JAR log4j2.xml中有一个log4j2.xml ,它由log4j而不是我的配置文件获取。

How can I get Maven to exclude this file from the JAR dependencies? 如何使Maven从JAR依赖项中排除此文件?

...before its suggested, I can't use the system property to set the log4j2.xml file explicitly as I want to be able to start my project without setting any JVM variables in the IDE. ...在提出建议之前,我无法使用system属性显式设置log4j2.xml文件,因为我希望能够启动我的项目而无需在IDE中设置任何JVM变量。

The shade plugin can exclude specific files - see here . shade插件可以排除特定文件-请参见此处 Also I'd try if having your config file before the unwanted one on the classpath would make log4j pick yours up. 另外,我会尝试在类路径上不需要的配置文件之前放置您的配置文件,以使log4j接您的配置文件。 Also according to the docs log4j2-test.xml and log4j2.json on the classpath have precedence over log4j2.xml unless log4j.configurationFile system property is set, which btw you can also do from maven, so you don't have to set anything in your IDE. 同样根据文档的 log4j2-test.xml和log4j2.json在类路径上优先于log4j2.xml,除非设置了log4j.configurationFile系统属性,这也可以从maven中完成,因此您不必进行任何设置在您的IDE中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM