Maven Exclude logback.xml in Jar file

摘要: This example shows you how to use Maven to exclude the logback.xml file from the final Jar file.

This example shows you how to use Maven to exclude the logback.xml file from the final Jar file.

Note
Please, DO NOT include the logback.xml into the final Jar file, it will cause multiple logback.xml files in the classpath, if someone is using your Jar, you may override other’s logging configurations accidentally.
pom.xml
<project>
  <build>
    <plugins>
	<!-- Make this jar executable -->
	<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-jar-plugin</artifactId>
		<configuration>
		        <!-- exclude logback.xml -->
			<excludes>
				<exclude>**/logback.xml</exclude>
			</excludes>
			<archive>
			   <manifest>
			     <mainClass>com.mkyong.core.crawler.App</mainClass>
		           </manifest>
			</archive>
		</configuration>
	</plugin>
    </plugins>
  </build>
</project>

You can still pass in your custom logback.xml file via logback.configurationFile system property like this

$ java -jar -Dlogback.configurationFile=/full_path/logback.xml final.jar

上一篇: Gradle bootstrap class path not set in conjunction with -source 1.5
下一篇: Nginx : Block Referrer Spam
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号