简体   繁体   中英

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. 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.

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. However you are overriding those with manual org.springframework dependencies from different Spring versions. You are mixing 2.5.1, 3.1.0, 3.1.3, 4.0.6 and 4.1.3. Mixing jars from different versions of any framework is a bad idea they are generally incompatible.

To fix, remove the org.springframework dependencies, those interfere/break the Spring Boot managed dependencies.

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 . 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'

}

NOTES

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 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).

I would also suggest replacing C3P0 with the default HikariCP (saves you a dependency and is imho a better connection pool).

You could also remove the version from the GSON dependency as Spring Boot also manages that (and that way you have a compatible version).

remove dependency spring-webmvc . Because AsyncSupportConfigurer is a class that exists since 3.2.

In fact, you can remove the org.springframework related dependencies. And it is safe.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM