Maven: NoClassDefFoundError in the main thread

后端 未结 2 1966
Happy的楠姐
Happy的楠姐 2020-12-14 17:33

I am currently building a little Apache-Mina Server app. I am using Maven to build it. When i try to run the jar, I get the following error:

    Exception in         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-14 17:50

    When you run from Eclipse, Eclipse configures the class path for you. Therefore, you don't run into this issue.

    When you are running outside of Eclipse, you need to set up the CLASSPATH either by providing the path to these jar files ie file:/dev/libs/mina-core-2.0.3.jar in the MANIFEST.MF or by adding the -cp option when executing the app. Don't forget that the entries in the class-path in the manifest file are either relative to the JAR in which they are embedded or absolute path to a local file directory.

    Your other option is to package it as one jar using the maven assembly plugin jar-with-dependencies.

提交回复
热议问题