public class testBatisController {
@Autowired
private UserService userService ;
@RequestMapping("/hello1")
public ModelAndView hello1()
return new ModelAndView("hello", "message",1);
}
我不注入那段service没事情一写注入就报这个错误:
No qualifying bean of type [net.spring.servoce.UserService] 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)}
ä½ çä½ çServiceå±çåå£æ¯ä¸æ¯æå¤ä¸ªå®ç°ç±»ï¼æ¯å¦UserServiceè¿æUserServiceImpl_1åUserServiceImpl_2两个å®ç°ç±»ï¼å¦ææï¼å¯ä»¥ç¨
@Qualifier("userService_1")è¿è¡ç»ç²åº¦çBeanæ³¨å ¥ï¼Springé»è®¤æ¯ætypeæ³¨å ¥ï¼å¤ä¸ªå®ç°ç±»ä¸æå®å ·ä½å®ç°ç±»åæ¯ä¼æ¥éçï¼ï¼ï¼ï¼
@Qualifier("userService_1")è¿è¡ç»ç²åº¦çBeanæ³¨å ¥ï¼Springé»è®¤æ¯ætypeæ³¨å ¥ï¼å¤ä¸ªå®ç°ç±»ä¸æå®å ·ä½å®ç°ç±»åæ¯ä¼æ¥éçï¼ï¼ï¼ï¼
温馨提示:答案为网友推荐,仅供参考