How to handle with CLASSPATH in Maven project?

前端 未结 1 862
清歌不尽
清歌不尽 2021-01-06 01:22

I am trying simple Maven app with Log4J ver 2-beta 9. In my pom.xml file I have these two dependencies (as is mentioned in Log4J Maven webpage):



        
相关标签:
1条回答
  • 2021-01-06 02:12

    Maven is a build tool. It doesn't help you much running the final application.

    You can use mvn exec:java -Dexec.mainClass="com.example.Sandbox" to run your app (see the question Maven Run Project) but this gets tedious when you have to pass arguments to it.

    You can get the classpath that Maven used to compile your application with mvn dependency:build-classpath

    That will print the classpath to the console. Note that it will be missing target/notification-1.0.0.jar

    Another useful tool in this area is the assembly plugin; it will create one very big JAR with all the dependencies rolled into a single file when you specify the descriptor jar-with-dependencies.

    0 讨论(0)
提交回复
热议问题