为什么这里要加个@Service?
来源:4-5 店铺注册之Service层的实现
慕斯卡7059763
2021-04-09
为什么这里要加个@Service才可以解决
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘shopServiceTest’: Unsatisfied dependency expressed through field ‘shopService’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.imooc.o2o.service.ShopService’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
这个问题?
写回答
2回答
-
同学好,如果不加@Service的话,spring容器就不知道什么类需要当作bean管理在容器里面了,加了@Service相当于是一种标记,让spring容器管理起来,方便@Autowired进行注入
012021-04-10 -
慕运维4052793
2021-05-30
麻烦你先学学SSM吧 这是SSM最基础的东西了
00
相似问题