spring mvc注入service报错是什么原因?
部分代码如下:报错:org.springframework.beans.factory.BeanCreationException: Error cr...
部分代码如下:
报错: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
需要的都提供了 应该没错,就是注入错误。求牛人解答 展开
报错: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
需要的都提供了 应该没错,就是注入错误。求牛人解答 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询