繁体   English   中英

Spring core/beans 5.3.18 升级项目无法启动 - Autowired 和 Bean 注释崩溃

[英]Spring core/beans 5.3.18 upgraded project won't start - Autowired and Bean annotations crashing

这是错误:

SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [com.mycompany.chassis.engine.core.web.listener.ChassisContextLoaderListener]
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'chassisApiSpringConfig': Unsatisfied dependency expressed through field 'sdpLoggingOn'; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'boolean'; nested exception is java.lang.IllegalArgumentException: Invalid boolean value [false,false]
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)

所以我升级到 spring-beans 5.3.18,得到了上面的错误,以为我很聪明并升级了 spring-core 以匹配 spring-beans 的版本,但我仍然得到这个错误。

我有 4 个单独的 pom 文件,请指导我如何为您提供最好的信息来帮助我解决这个问题。 将 spring-web 升级到相同版本会有帮助还是完全不同? 感觉Spring Beans不认识@Value了? 这是它抱怨的那一行。

@Value("${sdp.logging.on:false}")
private boolean sdpLoggingOn;

这是我目前拥有的进口商品:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

也许随着升级,Autowired 和 Value 现在不再出厂了?

将 spring 框架 bom 添加到您的 dependencyManagement 部分,以使所有 spring 框架 jars 保持同一版本。

<dependencyManagement>
    <dependencies>
            <dependency> 
                <groupId>org.springframework</groupId> 
                <artifactId>spring-framework-bom</artifactId> 
                <version>${spring.version}</version> 
                <type>pom</type> 
                <scope>import</scope> 
            </dependency> 
        </dependencies> 
</dependencyManagement>

对于多个 pom 文件,根据我的经验,最好让它们共享一个管理依赖关系的公共父 pom。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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