原因:java.lang.ClassNotFoundException:org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer

原因:java.lang.ClassNotFoundException:org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer,java,spring,hibernate,spring-boot,spring-mvc,Java,Spring,Hibernate,Spring Boot,Spring Mvc,正在尝试将旧应用程序转换为spring boot应用程序,并出现上述错误。我已经看到了很多关于缺少依赖项的线程,但我不确定我缺少了哪一个,如果我真的缺少一个开始?代码的任何其他部分都没有缺少库,但我显然缺少了什么?或者再想想,是不是我导入了不必要的依赖项,这些依赖项使应用程序变得杂乱无章,无法启动 有关包含依赖项的gradle.build的修订片段以及堆栈跟踪的修订列表,请参见下文 dependencies { compile group: 'javax.mail', name: 'ma

正在尝试将旧应用程序转换为spring boot应用程序,并出现上述错误。我已经看到了很多关于缺少依赖项的线程,但我不确定我缺少了哪一个,如果我真的缺少一个开始?代码的任何其他部分都没有缺少库,但我显然缺少了什么?或者再想想,是不是我导入了不必要的依赖项,这些依赖项使应用程序变得杂乱无章,无法启动

有关包含依赖项的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'

}


删除依赖项
SpringWebMVC
。因为
AsyncSupportConfigurer
是自3.2以来存在的类


事实上,您可以删除与
org.springframework
相关的依赖项。而且它是安全的。

您的依赖关系有点混乱。您的依赖项已经由
springbootstarter-*
依赖项管理。但是,您正在覆盖那些来自不同Spring版本的手动
org.springframework
依赖项。您正在混合2.5.1、3.1.0、3.1.3、4.0.6和4.1.3。混合来自任何框架的不同版本的jar是一个坏主意,因为它们通常是不兼容的

要修复,请删除
org.springframework
依赖项,这些依赖项会干扰/破坏Spring引导管理的依赖项

接下来,您不需要使用
springbootgradle插件作为依赖项,最后,
javax.mail
内容是
springbootstartermail
的一部分。A

这将产生以下依赖项列表

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'

}
笔记 根据您正在使用的Spring Boot版本,您还可以使用石英的
Spring Boot starter quartz
(或从依赖项中删除
version
元素)

Spring Boot 2.x不支持log4j 1,因此您可能希望将其替换为logback(默认)或log4j2(使用
Spring-Boot-starter-log4j2
依赖项)

我还建议将C3P0替换为默认的HikariCP(为您节省了一个依赖项,imho是一个更好的连接池)


您还可以从GSON依赖项中删除
版本
,因为springboot也可以管理它(这样您就有了一个兼容的版本)

您正在混合来自不同spring版本的罐子。删除所有
org.springframework
依赖项。这些都已经在
springbootstarter
依赖项中。还要删除
javax.mail
依赖项,并将
spring boot starter mail
添加为依赖项。我也几乎不相信你会需要插件作为一种依赖。
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'

}