Maven: NoClassDefFoundError in the main thread
2022-09-01 23:22:16
我目前正在构建一个小的Apache-Mina Server应用程序。我正在使用Maven来构建它。当我尝试运行jar时,我得到以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/mina/filter/codec/ProtocolCodecFactory
Caused by: java.lang.ClassNotFoundException: org.apache.mina.filter.codec.Protoc olCodecFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: de.fr1zle.gpsserver.GpsServer. Program will exit.
在日食中运行不是问题。
以下是生成的清单的外观:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: fr1zle
Build-Jdk: 1.6.0_23
Main-Class: de.fr1zle.gpsserver.GpsServer
Class-Path: commons-lang-2.1.jar plexus-utils-1.1.jar junit-4.8.2.jar
log4j-1.2.14.jar slf4j-jdk14-1.5.11.jar slf4j-api-1.5.11.jar antlr-2.
7.6.jar commons-collections-3.1.jar dom4j-1.6.1.jar hibernate-commons
-annotations-3.2.0.Final.jar hibernate-jpa-2.0-api-1.0.0.Final.jar jt
a-1.1.jar hibernate-annotations-3.5.6-Final.jar hibernate-core-3.5.6-
Final.jar mysql-connector-java-5.1.15.jar mina-core-2.0.3.jar
这是我的pom.xml的(部分):
<groupId>de.fr1zle.gpsserver</groupId>
<artifactId>GPSServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>GPSServer</name>
<packaging>jar</packaging>
<description>Tracks location of GPS modules and the information they submit.</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>de.fr1zle.gpsserver.GpsServer</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
我在这里做错了什么?