springMVC 注解 启动时报错

[ERROR][2014-12-13 15:32:54,041][org.springframework.web.servlet.DispatcherServlet]Context initialization failed
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 com.mvc.service.IUserService com.mvc.controller.UserController.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.mvc.service.IUserService] 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)}

at java.lang.Thread.run(Thread.java:662)

首先你要学会看异常 org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class 这句是没有找到对应的class, 其次你要看,这个异常是LoadBeanClass时候出现的,这证明没有找到对应的bean,而这个bean对应的是在ContextLoaderListener读/WEB-INF/annomvc-servlet.xml时候出现的,这证明没有找到相应的MVC的类库,因此,是你少了jar包而引起的异常。 解决方法是加入jar包即可。 我不知道你的是2.X还是3.X 2.X加入spring-webmvc.jar 即可 3.X加入org.springframework.web.servlet-3.1.1.RELEASE.jar即可 这些jar都可以再spring的官方网站下载,也可以使用meavn下载。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-12-13
你吧userController的
@Resources

private IUserService userService;
这样写试试本回答被网友采纳

相关了解……

你可能感兴趣的内容

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