【springboot】报错Error creating bean with name ‘xxxController‘: Injection of resource dependencies fail

文章描述了一次SpringBoot项目中遇到的BeanCreationException,源于UserAddressController中的@Resource注入未找到UserAddressServiceImpl。解决办法是在Service层添加@Service注解。
摘要由CSDN通过智能技术生成
springboot后端报错如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userAddressController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.yu.app.moudles.service.UserAddressServiceImpl’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:324) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]

后续原因与解决

原因:
在controller中注入了@Resource注解并调用service的方法,但是在service层没有注入@Service注解导致无法正常使用service层相关方法。(此过程中代码无相关报错,依赖也是正常注入跳转,但是无法正常启动后端程序)

后续解决:
在对应的service层加入如下注解:

import org.springframework.stereotype.Service;

@Service
public class UserAddressService {
	.....
}
  • 16
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值