java - How do I use log4j with Maven and executable jar file? -
i'm trying log4j working in simple application i'm getting message:
exception in thread "main" java.lang.noclassdeffounderror: org/apache/log4j/logger i execute application command:
java -jar lunchtracker-1.0-snapshot.jar the log4j.properties file in src/main/resources. here pom.xml:
<project <snip -- messing formatting>> <modelversion>4.0.0</modelversion> <groupid>net.uofitorn</groupid> <artifactid>lunchtracker</artifactid> <packaging>jar</packaging> <version>1.0-snapshot</version> <name>lunchtracker</name> <url>http://maven.apache.org</url> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-jar-plugin</artifactid> <configuration> <archive> <manifest> <addclasspath>true</addclasspath> <classpathprefix>lib/</classpathprefix> <mainclass>net.uofitorn.lunchtrackerserver</mainclass> </manifest> </archive> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupid>log4j</groupid> <artifactid>log4j</artifactid> <version>1.2.16</version> <scope>compile</scope> </dependency> </dependencies> </project> here java code:
import org.apache.log4j.logger; <snip> logger logger = logger.getlogger(lunchtrackerserver.class.getname()); logger.debug("server started"); i think problem log4j jar not being included in jar file. when unzip jar don't see it. how maven include log4j dependency in jar?
you need provide log4j dependency @ runtime, , provide need pack log4j artifact jar, here how can create fat jar
Comments
Post a Comment