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号