Service层代码中添加了@Value注解启动异常

在SpringBoot项目中,Service层添加@Value注解导致启动时出现异常。问题描述显示,仅此改动即触发错误。经过原因分析,可能是与Lombok的@AllArgsConstructor注解冲突。解决方案是移除@AllArgsConstructor,保留@Service、@Slf4j,并通过@Resource注解注入依赖。目前未找到根本原因,期待有经验者提供解答。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题复现:

SpringBoot项目的service层,添加了@Value注解

	@Value("${com.****.****.****.uploadUrl}")
    private String uploadUr ;

导致项目启动时,抛出异常,异常如下:

问题描述

其他地方不动, 只是添加了@Value注解(相应配置已添加),启动就会报以下错误,

15:51:19.092 [INFO ] [fuxi-disruptor-fuxi_disruptor_consumer_-31] .NacosClientRegisterRepository[161]: register metadata success: /contract/icosLoanAfter/**
15:51:19.144 [INFO ] [fuxi-disruptor-fuxi_disruptor_consumer_-18] .NacosClientRegisterRepository[161]: register metadata success: /contract/IcosRepayMentDate/**
15:51:19.326 [INFO ] [fuxi-disruptor-fuxi_disruptor_consumer_-24] .NacosClientRegisterRepository[161]: register metadata success: /contract/icosWipedBadDebts/**
15:51:19.362 [INFO ] [fuxi-disruptor-fuxi_disruptor_consumer_-23] .NacosClientRegisterRepository[161]: register metadata success: /contract/wechatPayment/**
15:51:19.660 [WARN ] [main] letWebServerApplicationContext[559]: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'applyRecordController' defined in file [C:\workSpace\afs-contract\afs-contract-\afs-contract--biz\target\classes\com\gwmfc\icos\\common\controller\ApplyRecordController.class]: Unsatisfied dependency expressed through constructor parameter 7; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'RevokeHandleServiceImpl' defined in file [C:\workSpace\afs-contract\afs-contract-\afs-contract--biz\target\classes\com\gwmfc\icos\\common\service\impl\RevokeHandleServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 9; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
15:51:19.670 [INFO ] [main] b.d.d.DynamicRoutingDataSource[215]: dynamic-datasource start closing ....
15:51:19.673 [INFO ] [main] c.a.d.p.DruidDataSource       [2032]: {dataSource-2} closing ...
15:51:19.678 [INFO ] [main] c.a.d.p.DruidDataSource       [2104]: {dataSource-2} closed
15:51:19.679 [INFO ] [main] c.a.d.p.DruidDataSource       [2032]: {dataSource-1} closing ...
15:51:19.681 [INFO ] [main] c.a.d.p.DruidDataSource       [2104]: {dataSource-1} closed
15:51:19.682 [INFO ] [main] b.d.d.DynamicRoutingDataSource[219]: dynamic-datasource all closed success,bye
15:51:19.684 [WARN ] [main] tationConfigApplicationContext[1016]: Exception thrown from ApplicationListener handling ContextClosedEvent
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'rabbitConnectionFactory': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:212) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
        at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:245) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
        at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:197) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicati
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值