Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring &引用;NoClassDefFoundError:GenericApplicationListener“;从弹簧防尘套1.3.0M1切换到1.3.0M2时_Spring_Spring Boot - Fatal编程技术网

Spring &引用;NoClassDefFoundError:GenericApplicationListener“;从弹簧防尘套1.3.0M1切换到1.3.0M2时

Spring &引用;NoClassDefFoundError:GenericApplicationListener“;从弹簧防尘套1.3.0M1切换到1.3.0M2时,spring,spring-boot,Spring,Spring Boot,在我的Spring Starter创建的Soring Boot应用程序中,我将Spring Boot从1.3.0M1切换到1.3.0M2。当尝试启动应用程序时(从STS 3.7.0或通过spring boot:在命令行上运行),我遇到以下异常: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at s

在我的Spring Starter创建的Soring Boot应用程序中,我将Spring Boot从1.3.0M1切换到1.3.0M2。当尝试启动应用程序时(从STS 3.7.0或通过spring boot:在命令行上运行),我遇到以下异常:

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:435)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.logging.ClasspathLoggingApplicationListener
        at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:385)
        at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:362)
        at org.springframework.boot.SpringApplication.initialize(SpringApplication.java:231)
        at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:206)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:971)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:960)
        at com.daimler.daivb.services.application.dummyservice.DummyServiceApplication.main(DummyServiceApplication.java:18)
        ... 6 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/event/GenericApplicationListener
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
        at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:378)
        ... 12 more
Caused by: java.lang.ClassNotFoundException: org.springframework.context.event.GenericApplicationListener
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 25 more

SpringBoot为您和客户管理一系列依赖项。SpringBoot显然是基于SpringFramework的,并且使用了最新和最好的版本,因此您应该不惜一切代价避免自行修复SpringFramework版本

如果您已升级到较新版本(包括错误修复或其他内容),请确保在升级Spring Boot之前删除覆盖,因为它所需的新版本可能与您的覆盖不兼容

如果您正在使用在Spring框架上也提供依赖关系管理的其他项目(如Spring Cloud),请确保Spring Boot的依赖关系管理优先。使用Maven时,请确保将
spring引导依赖项添加为

根据上述错误,应用程序无法找到从jar依赖项定义的类
GenericApplicationListener
是从spring版本4.2中添加的


将您的Spring版本升级到4.2并重新检查。

我也遇到了同样的问题,因为我的POM有一个属性部分,其中包含从另一个项目复制的
标记


删除属性部分中任何可能与Spring启动库冲突的
标记。

尝试通过排除4.1.6可传递依赖项,将依赖项显式添加到Spring context 4.2.0.RC3中,导致以下错误:
原因:java.lang.NoSuchMethodError:org.springframework.beans.factory.config.ConfigurableBeanFactory.getSingletonMutex()Ljava/lang/Object
Spring Boot 4.1应该使用Spring 4.2,确保您没有在pom中指定
Spring.version
属性,或者没有强制使用4.1.6版本的其他依赖项。我遇到了同样的问题。我更新了我的SpringCloud应用程序以使用SpringBoot1.3.0.M5版本,它似乎对SpringFramework4.1.6有很多依赖。在依赖关系树中,我注意到一些是4.2.1,但大多数仍然是4.1.6。我没有一个明确的4.1.6 spring.version,我通过运行带-U的构建来更新所有快照依赖项,解决了这个问题。我有一个类似的问题,在我的构建中将我的spring版本从4.1.6更改为4.2.1。gradle解决了这个问题。我也会选择这个答案。我的pom.xml对spring测试mvc和spring测试有两种不同的依赖项声明,这显然导致了类加载混乱。删除spring test mvc为我解决了这个问题。上次我遇到这个问题时,从spring Boot版本
1.3.7
1.3.8
的更新修复了这个问题。
[INFO] com.company.services.application:dummyservice:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:1.3.0.M2:compile
[INFO] |  +- org.springframework.boot:spring-boot:jar:1.3.0.M2:compile
[INFO] |  |  \- org.springframework:spring-context:jar:4.1.6.RELEASE:compile
[INFO] |  \- org.springframework.boot:spring-boot-autoconfigure:jar:1.3.0.M2:compile
[INFO] |     \- org.yaml:snakeyaml:jar:1.15:compile
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/event/GenericApplicationListener