[英]Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer
trying to convert and old app into a spring boot app and getting the above error. 尝试将旧应用转换为Spring Boot应用并得到上述错误。 I've been seeing a lot of threads regarding missing dependencies but I'm not sure which one I'm missing, if I am indeed missing one to begin with?
我已经看到了很多有关缺少依赖项的线程,但是我不确定是否丢失了一个(如果我确实确实缺少一个)? No libraries are missing from any other portion of code but I'm clearly missing something?
代码的任何其他部分都没有缺少库,但是我显然缺少了什么吗? Or on second thought it is could it be I'm import unnecessary dependencies that are cluttering up the app making it not start as well?
还是第二次想到这可能是因为我导入了不必要的依赖项,从而使应用程序变得混乱,导致应用程序无法正常启动?
See below for a redacted snippet of the gradle.build containing dependencies and also a redacted list of the stack trace. 请参阅下面的gradle.build的摘要片段,其中包含依赖项以及堆栈跟踪的摘要列表。
dependencies {
compile group: 'javax.mail', name: 'mail', version:'1.4.1'
compile group: 'com.google.code.gson', name: 'gson', version:'2.3'
compile group: 'commons-codec', name: 'commons-codec', version:'20041127.091804'
compile group: 'org.jsoup', name: 'jsoup', version:'1.7.2'
compile group: 'commons-io', name: 'commons-io', version:'2.5'
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.5'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version:'4.3.5'
compile group: 'org.json', name: 'json', version:'20140107'
compile group: 'com.itextpdf.tool', name: 'xmlworker', version:'5.5.6'
compile group: 'log4j', name: 'log4j', version:'1.2.17'
compile group: 'org.quartz-scheduler', name: 'quartz', version:'2.2.1'
compile group: 'org.quartz-scheduler', name: 'quartz-jobs', version:'2.2.1'
compile group: 'org.springframework', name: 'spring-context-support', version:'3.1.3.RELEASE'
compile group: 'org.springframework', name: 'spring-webmvc', version:'3.1.0.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version:'3.1.0.RELEASE'
compile group: 'org.springframework', name: 'spring-jdbc', version:'4.0.6.RELEASE'
compile group: 'c3p0', name: 'c3p0', version:'0.9.1.2'
compile group: 'mssqlserver', name: 'sqljdbc4', version:'3.0'
compile group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: '2.1.6.RELEASE', ext: 'pom'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-starter-web'
compile group: 'org.springframework', name: 'spring-orm', version: '2.5.1'
compile group: 'org.springframework', name: 'spring-orm', version: '4.3.18.RELEASE'
}
java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$EndpointWebMvcConfiguration due to org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55) ~[spring-boot-autoconfigure-1.5.14.RELEASE.jar:1.5.14.RELEASE]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:444) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
etc...
at com.dish.wfm.controller.SamsungUpdateJobApplication.main(SamsungUpdateJobApplication.java:17) [classes/:na]
Caused by: java.lang.NoClassDefFoundError: org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_211]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_211]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_211]
etc...
Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_211]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_211]
... 36 common frames omitted
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration] for bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': problem with class file or dependent class; nested exception is java.lang.VerifyError: class org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration overrides final method configureHandlerExceptionResolvers.(Ljava/util/List;)V
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1394) ~[spring-beans-4.3.18.RELEASE.jar:4.3.18.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:641) ~[spring-beans-4.3.18.RELEASE.jar:4.3.18.RELEASE]
etc...
Caused by: java.lang.VerifyError: class org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration overrides final method configureHandlerExceptionResolvers.(Ljava/util/List;)V
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_211]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_211]
etc...
Your dependencies are a bit of a mess. 您的依赖关系有点混乱。 You have dependencies that are already managed by the
spring-boot-starter-*
dependencies. 您具有已经由
spring-boot-starter-*
依赖关系管理的依赖关系。 However you are overriding those with manual org.springframework
dependencies from different Spring versions. 但是,您将覆盖来自不同Spring版本的那些具有手动
org.springframework
依赖项的文件。 You are mixing 2.5.1, 3.1.0, 3.1.3, 4.0.6 and 4.1.3. 您正在混合2.5.1、3.1.0、3.1.3、4.0.6和4.1.3。 Mixing jars from different versions of any framework is a bad idea they are generally incompatible.
混合来自任何框架的不同版本的jar是一个坏主意,因为它们通常不兼容。
To fix, remove the org.springframework
dependencies, those interfere/break the Spring Boot managed dependencies. 要修复,请删除
org.springframework
依赖项,这些依赖项会干扰/破坏Spring Boot托管的依赖项。
Next you don't need the spring-boot-gradle-plugin
as a dependency and finally the javax.mail
stuff is part of the spring-boot-starter-mail
. 接下来,您不需要使用
spring-boot-gradle-plugin
作为依赖项,并且最后javax.mail
内容是spring-boot-starter-mail
。 A 一种
This would result in the following list of dependencies 这将导致以下依赖项列表
dependencies {
compile group: 'com.google.code.gson', name: 'gson', version:'2.3'
compile group: 'commons-codec', name: 'commons-codec', version:'20041127.091804'
compile group: 'org.jsoup', name: 'jsoup', version:'1.7.2'
compile group: 'commons-io', name: 'commons-io', version:'2.5'
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.5'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version:'4.3.5'
compile group: 'org.json', name: 'json', version:'20140107'
compile group: 'com.itextpdf.tool', name: 'xmlworker', version:'5.5.6'
compile group: 'log4j', name: 'log4j', version:'1.2.17'
compile group: 'org.quartz-scheduler', name: 'quartz', version:'2.2.1'
compile group: 'org.quartz-scheduler', name: 'quartz-jobs', version:'2.2.1'
compile group: 'c3p0', name: 'c3p0', version:'0.9.1.2'
compile group: 'mssqlserver', name: 'sqljdbc4', version:'3.0'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-mail'
}
Depending on the Spring Boot version you are using you could also use spring-boot-starter-quartz
for quartz (or remove the version
element from the dependencies). 根据您使用的Spring Boot版本,您还可以使用
spring-boot-starter-quartz
来实现石英(或从依赖项中删除version
元素)。
Spring Boot 2.x doesn't support log4j 1 so you might want to replace that with logback (the default) or log4j2 (using the spring-boot-starter-log4j2
dependency). Spring Boot 2.x不支持log4j 1,因此您可能希望将其替换为logback(默认)或log4j2(使用
spring-boot-starter-log4j2
依赖项)。
I would also suggest replacing C3P0 with the default HikariCP (saves you a dependency and is imho a better connection pool). 我还建议用默认的HikariCP替换C3P0(为您节省依赖关系,并且是更好的连接池)。
You could also remove the version
from the GSON dependency as Spring Boot also manages that (and that way you have a compatible version). 您还可以从GSON依赖项中删除该
version
,因为Spring Boot也可以管理该版本(这样您就可以拥有兼容的版本)。
remove dependency spring-webmvc
. 删除依赖
spring-webmvc
。 Because AsyncSupportConfigurer
is a class that exists since 3.2. 因为
AsyncSupportConfigurer
是从3.2开始存在的类。
In fact, you can remove the org.springframework
related dependencies. 实际上,您可以删除与
org.springframework
相关的依赖项。 And it is safe. 而且很安全。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.