【问题标题】:Failed to read candidate component class in spring mvc & spring boot在 spring mvc 和 spring boot 中读取候选组件类失败
【发布时间】:2022-01-03 20:45:46
【问题描述】:

我在spring mvc项目中添加spring boot项目作为依赖,应用程序可以成功运行但是当我调用服务时遇到以下错误

上下文初始化失败 org.springframework.beans.factory.BeanDefinitionStoreException:失败 读取候选组件类:嵌套异常是 org.springframework.core.annotation.AnnotationConfigurationException: 注释中的属性“proxyBeanMethods” [org.springframework.boot.SpringBootConfiguration] 被声明为 @AliasFor 注释中不存在的属性“proxyBeanMethods” [org.springframework.context.annotation.Configuration].;嵌套的 例外是 java.lang.NoSuchMethodException: org.springframework.context.annotation.Configuration.proxyBeanMethods()

【问题讨论】:

    标签: java spring-boot spring-mvc


    【解决方案1】:

    注解中的属性“proxyBeanMethods” [org.springframework.boot.SpringBootConfiguration] 被声明为 @AliasFor 注释中不存在的属性“proxyBeanMethods” [org.springframework.context.annotation.Configuration].;嵌套的 例外是 java.lang.NoSuchMethodException: org.springframework.context.annotation.配置.proxyBeanMethods()

    主要是抱怨你的@Configuration没有一个叫proxyBeanMethods的属性。从 javadoc 检查,这个属性是从 Spring 5.2 开始添加的。

    很可能是因为您将 spring 版本与 spring-boot 版本混淆了。您的 spring 版本太旧(5.2 之前),以至于没有定义 @Configuration 的上述属性。

    您应该使用版本由您使用的 spring-boot 版本定义的 spring 框架。告诉我pom.xml,我可以帮助检查哪个<dependency> 导致了这种版本不匹配。谢谢。

    【讨论】:

    • 4.3.3.RELEASE
    • 好的。因此,相应地修改 spring 版本以匹配 spring-boot 。首先找出你的spring-boot的版本。谢谢
    猜你喜欢
    • 2012-01-30
    • 2021-12-29
    • 2014-05-11
    • 1970-01-01
    • 2018-08-23
    • 2020-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多