springmvc只要注入service就报错,谁能帮我看看啊
publicclasstestBatisController{@AutowiredprivateUserServiceuserService;@RequestMappin...
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)} 展开
@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)} 展开
2014-09-08
展开全部
你看你的Service层的借口枝哪是不是有多个实现类,比如UserService还猛银码有UserServiceImpl_1和UserServiceImpl_2两个实现类?如果有,可以用
@Qualifier("userService_1")进行细粒度的Bean注入,Spring默认是按type注入,多个实现类不指定具体实现类型是会报错的!!!搏前!
@Qualifier("userService_1")进行细粒度的Bean注入,Spring默认是按type注入,多个实现类不指定具体实现类型是会报错的!!!搏前!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询