栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

添加spring-security-oauth2后无法实例化接口org.springframework.context.ApplicationListener

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

添加spring-security-oauth2后无法实例化接口org.springframework.context.ApplicationListener

解决了示例pom的问题后,我现在可以看到故障的完整堆栈跟踪:

Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.context.logging.ClasspathLoggingApplicationListener    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:439)    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:418)    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:409)    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:268)    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:247)    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245)    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233)    at mahlzeit.api.Application.main(Application.java:14)Caused by: java.lang.NoClassDefFoundError: org/springframework/context/event/GenericApplicationListener    at java.lang.ClassLoader.defineClass1(Native Method)    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)    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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)    at org.springframework.util.ClassUtils.forName(ClassUtils.java:255)    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:431)    ... 7 moreCaused 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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)    ... 21 more

问题的根本原因

org.springframework.context.event.GenericApplicationListener
是不在类路径上。此类是
spring-context
模块的一部分,并且是Spring framework 4.2中的新增类。

查看pom,您没有使用Boot的依赖项管理(通过导入

spring-boot-dependencies
Bom或通过
spring-boot-starter-parent
用作项目的父项来进行管理。这意味着未管理任何传递性依赖项的版本。这在您的项目中引起了问题正在使用4.0.9.RELEASE通过
spring-context
传递
spring-security-oauth2

我强烈建议您使用Spring Boot的依赖项管理。如果您不想这样做或由于某些未说明的原因而不能这样做,则必须手动确保所有传递依赖项都支持版本。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/466255.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号