JAVA/Spring异常线程&Main"java.lang.NoClassDefFoundError:org/springframework/beans/factory/ListableBeanFactory

Java / Spring exception thread quot;mainquot; java.lang.NoClassDefFoundError: org/springframework/beans/factory/ListableBeanFactory(JAVA/Spring异常线程Mainquot;java.lang.NoClassDefFoundError:org/springframework/beans/factory/ListableBeanFactory)

本文介绍了JAVA/Spring异常线程&Main"java.lang.NoClassDefFoundError:org/springframework/beans/factory/ListableBeanFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在自学一门新语言:Java with Spring。

我已经设法在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>tech.benjaminpradon</groupId>
  <artifactId>springboot</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>benjaminpradon</name>


 <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
</parent>


<dependencies>
    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>


<!-- Version -->
<properties>
    <java.version>1.8</java.version>
</properties>
</project>

我还创建了Spring应用程序运行程序:

 package springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class LearningJava {

    public static void main(String[] args) {
        SpringApplication.run(LearningJava.class, args);

    }

}

但是,当我尝试运行它时,出现错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/beans/factory/ListableBeanFactory
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    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)
    at springboot.LearningJava.main(LearningJava.java:10)
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.ListableBeanFactory
    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)
    ... 13 more

我认为我需要创建一个Resources控制器(RestController)。 因此,我创建了一个:

package springboot.hello;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

@RequestMapping("/hello")
    public String Hi() {
        return "Hi";
    }
}

但是,这不会改变任何事情。

因为我是纽比人,我真的需要帮助。 谢谢。

推荐答案

正如@Mallikarjun提到的,我应该

删除.m2文件夹,然后重新运行或再次更新依赖项

这篇关于JAVA/Spring异常线程&Main&quot;java.lang.NoClassDefFoundError:org/springframework/beans/factory/ListableBeanFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:JAVA/Spring异常线程&Main&quot;java.lang.NoClassDefFoundError:org/springframework/beans/factory/ListableBeanFactory

基础教程推荐