启动 Spring 项目的时候提示下面的错误信息:
Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.context.logging.LoggingApplicationListener
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:461)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:443)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:436)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:267)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:245)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at com.usvisatrack.common.data.Application.main(Application.java:18)
Caused by: java.lang.NoClassDefFoundError: org.springframework.context.event.GenericApplicationListener
at java.base/java.lang.ClassLoader.defineClassImpl(Native Method)
at java.base/java.lang.ClassLoader.defineClassInternal(ClassLoader.java:466)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:427)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:1110)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:898)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:806)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:764)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:1074)
at java.base/java.lang.Class.forNameImpl(Native Method)
at java.base/java.lang.Class.forName(Class.java:417)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:284)
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:454)
... 7 more
Caused by: java.lang.ClassNotFoundException: org.springframework.context.event.GenericApplicationListener
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:766)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:1074)
... 21 more
下面的界面为错误的信息:
问题和解决
上面的问题简单来说就是在你的 Spring 项目中有 2 个版本的 Spring ,你需要找到 Maven 的配置文件中确定只有一个 Spring Boot 的版本。
找到你的 pom配置文件,确保只有一个 Spring Boot 在你的配置文件中。
我的情况是上面老的 spring-context 和新版本的 Spring Boot 冲突了。
删掉上面的依赖就可以了。
https://www.ossez.com/t/spring-loggingapplicationlistener/14067
标签:java,提示,Spring,LoggingApplicationListener,SpringApplication,base,springframework From: https://www.cnblogs.com/huyuchengus/p/16625393.html