我在contorller类中用注解的方式实现Service就会报错
报错内容如下
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private supermarket.service.UserServiceSuper supermarket.controller.UserController.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [supermarket.service.UserServiceSuper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=userServiceMark)}
但是我若是用context去取userService就正常运行,UserServiceSuper userService=(UserServiceSuper)context.getBean("userServiceMark");
就是用注解就不行,我查了 网上说是@Autowired的错误,但我找不出来. 恳求前辈指点一下呀 感谢
问题关键就是controller层无法通过注解调用
contorller中 中用注解调用ServiceImpl层异常,求前辈指点
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-