springmvc只要注入service就报错,谁能帮我看看啊

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注入,多个实现类不指定具体实现类型是会报错的!!!!
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网