【问题标题】:Spring boot autoconfigure application start failsSpring Boot 自动配置应用程序启动失败
【发布时间】:2021-07-21 04:41:40
【问题描述】:

我已经构建了自己的启动器,但自动配置步骤因依赖冲突而失败。

这些是我的启动项目和上游项目正在使用的 Spring Boot 版本

'spring-boot-gradle-plugin', version2.1.8.RELEASE

'spring-boot-autoconfigure',版本:'2.4.1'

***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
    org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration.lambda$addResourceHandlers$0(W
ebMvcAutoConfiguration.java:411)
The following method did not exist:
    'org.springframework.web.servlet.config.annotation.ResourceHandlerRegistration org.springframework.web.servlet.config.annotation.Re
sourceHandlerRegistration.addResourceLocations(org.springframework.core.io.Resource[])'
The method's class, org.springframework.web.servlet.config.annotation.ResourceHandlerRegistration, is available from the following loca
tions:
    jar:file:/opt/eureka/app.jar!/BOOT-INF/lib/spring-webmvc-5.3.2.jar!/org/springframework/web/servlet/config/annotation/ResourceHandl
erRegistration.class
The class hierarchy was loaded from the following locations:
    org.springframework.web.servlet.config.annotation.ResourceHandlerRegistration: jar:file:/opt/eureka/app.jar!/BOOT-INF/lib/spring-we
bmvc-5.3.2.jar!/
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.web.servlet.config.an
notation.ResourceHandlerRegistration

【问题讨论】:

    标签: java spring spring-boot spring-mvc


    【解决方案1】:

    从您的日志中,我看到了两个可能的问题之一:

    1. 您将 spring-webmvc-5.3.2 覆盖到更高或更低版本的地方
    2. 您的起始代码存在问题(如果它配置了您的 WebMvc)

    尝试mvn dependency:treegradle dependencies 来探索依赖关系。 附上您的入门代码。

    【讨论】:

      【解决方案2】:

      我不得不使用 spring boot 2.4.1 来避免冲突。

      【讨论】:

        猜你喜欢
        • 2017-05-12
        • 2019-02-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-06
        • 2018-09-05
        相关资源
        最近更新 更多