Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\BCJ_DEC_2016\workspace\CoreJava\creditcardprocess\target>java -jar creditcardprocess-0.0.1-SNAPSHOT.jar
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
C:\BCJ_DEC_2016\workspace\CoreJava\creditcardprocess\target>
**MANIFEST.MF**
Manifest-Version: 1.0
Built-By: Bootcamp User 005
Class-Path: lib/spring-core-4.3.7.RELEASE.jar lib/commons-logging-1.2.
jar lib/spring-context-4.3.7.RELEASE.jar lib/spring-aop-4.3.7.RELEASE
.jar lib/spring-beans-4.3.7.RELEASE.jar lib/spring-expression-4.3.7.R
ELEASE.jar lib/mail-1.5.0-b01.jar lib/activation-1.1.1.jar lib/spring
-tx-4.3.7.RELEASE.jar lib/hibernate-core-4.3.3.Final.jar lib/jboss-lo
gging-3.1.3.GA.jar lib/jboss-logging-annotations-1.2.0.Beta1.jar lib/
jboss-transaction-api_1.2_spec-1.0.0.Final.jar lib/dom4j-1.6.1.jar li
b/xml-apis-1.0.b2.jar lib/hibernate-commons-annotations-4.0.4.Final.j
ar lib/hibernate-jpa-2.1-api-1.0.0.Final.jar lib/javassist-3.18.1-GA.
jar lib/antlr-2.7.7.jar lib/jandex-1.1.0.Final.jar lib/mysql-connecto
r-java-6.0.6.jar lib/commons-dbcp-1.4.jar lib/commons-pool-1.5.4.jar
lib/spring-webmvc-4.3.7.RELEASE.jar lib/spring-web-4.3.7.RELEASE.jar
lib/servlet-api-2.5.jar lib/spring-orm-4.3.7.RELEASE.jar lib/spring-j
dbc-4.3.7.RELEASE.jar
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_121
Main-Class: com.bcj.creditcardprocess.CreditCardMain
**POM.XML**
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bcj</groupId>
<artifactId>creditcardprocess</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>creditcardprocess</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.bcj.creditcardprocess.CreditCardMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-tools -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>4.3.3.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.mail/mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.5.0-b01</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.3.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
</dependencies>
</project>
在我的MANIFEST.MF文件中,它显示了spring-context依赖关系,但它再次引发了一个异常,说ClassNotFoundException:org.springframework.context.ApplicationContext。但它在日食中运行良好。为什么会这样?
答案 0 :(得分:0)
我认为你应该使用maven-assembly-plugin而不是maven-jar-plugin,因为它不包含对JAR文件的依赖。