August 14, 2022

Maven – Exclude log4j.properties in Jar file

This example shows you how to use Maven to exclude the log4j.properties file from your Jar file. Please, DO NOT include the log4j.properties into the final Jar file, it will cause multiple log4j.properties files in the classpath, if someone is depending on your Jar, you may accidentally override their logging configurations, depends which Jar is loaded first.

Maven – Exclude log4j.properties in Jar file Read More

How to create a jar file with Maven

In this tutorial, we will show you how to use Maven build tool, to create a single executable Jar, and how to deal with the project’s dependencies. Tools used :Maven 3.1.1 ; JDK 1.7 ; log4j 1.2.17 ; Joda-time 2.5 ; Eclipse 4.3 . We will demo how to use maven-dependency-plugin to copy all dependencies to target/dependency-jars/ folder, and use maven-jar-plugin to add the dependency classpath. Note: In future, if you want to move dateUtils.jar, make sure to copy its dependency-jars folder as well.

How to create a jar file with Maven Read More