Hi guys, I'm new to Maven, and I'm trying to integrate slf4j into a maven project. Here is my pom.xml file
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.9</version>
</dependency>
And I have these two lines in my main function
Logger logger = LoggerFactory.getLogger(App.class);
logger.info("Hello World");
The project is compiled and successfully packaged, but when I try to run it through
java -cp target / maven-1.0-SNAPSHOT.jar com.goutam.maven.App the following exception is thrown
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.goutam.maven.App.main(App.java:11)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
user2493476
source
share