为什么我在Spring基本应用程序中出错?

时间:2016-02-11 11:12:35

标签: java spring

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/c
ore/io/Resource
        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.core.io.Resourc
e
        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

我正在学习春天..所以我刚创建了基本的Spring应用程序..

我已经使用命令提示符编译了所有类(Student Model Class + Test Class包含Main方法) 并创建了applicationContext.xml。

2 个答案:

答案 0 :(得分:0)


检查你的类路径是否 添加了 spring-core 。他似乎没有找到它 (项目属性> Java构建路径> Librairies)

如果您使用Maven来管理依赖项,请添加 pom.xml

<dependency>
 <groupid>org.springframework</groupid>
 <artifactid>spring-core</artifactid>
 <version>${org.springframework.version}</version>
</dependency>

答案 1 :(得分:0)

确保已将以下依赖项添加到pom.xml文件中:

 <dependency>
     <groupid>org.springframework</groupid>
     <artifactid>spring-core</artifactid>
     <version>${org.springframework.version}</version>
  </dependency>