部分代码如下:
报错: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 myforum.service.UserTest myforum.controller.UserController.userTest; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [myforum.service.UserTest] 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)}
配置如下:web.xmlcontextConfigLocationclasspath:spring.xml,classpath:spring-hibernate.xmlspring mvc servletspringMvcorg.springframework.web.servlet.DispatcherServletspring mvc 配置文件contextConfigLocationclasspath:spring-mvc.xml1 springMvc*.action spring.xmlspring-mvc.xml
需要的都提供了 应该没错,就是注入错误。求牛人解答
从controller到service到dao全部检查一遍;
或者全部粘贴出来,才能看到问题。