Project在作为应用程序运行的Eclipse中运行良好。当试图运行由Maven构建的jar时,我收到以下错误:
C:\ test> java -jar SybaseTest.jar
C:\test>java -jar SybaseTest.jar
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
jar文件包含lib目录中的所有库: Libraries in the jar file
清单文件在类路径中有库spring-context-4.3.2.RELEASE.jar,另外11个是Maven依赖项。
Class-Path: . lib/spring-jdbc-4.3.2.RELEASE.jar lib/spring-beans-4.3.2
.RELEASE.jar lib/spring-core-4.3.2.RELEASE.jar lib/spring-tx-4.3.2.RE
LEASE.jar lib/spring-context-4.3.2.RELEASE.jar lib/spring-aop-4.3.2.R
ELEASE.jar lib/spring-expression-4.3.2.RELEASE.jar lib/commons-dbcp-1
.4.jar lib/commons-pool-1.6.jar lib/jconn4-7.0.jar lib/bcprov-jdk15on
-1.56.jar lib/commons-logging-1.2.jar
有什么建议吗?