在项目启动时报错:
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.hhh.backoffice.service.UserService com.hhh.backoffice.web.controller.UserController.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.hhh.backoffice.service.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)}
看看你的applicationContext.xml有没有配置自动扫描(下面这条语句)
再看看springmvc有没有配置自动扫描(下面这条语句)
<!--自动扫描service-->
<context:component-scan base-package="com.hhh.backoffice"/>
如果都配置了那就看看的你的service有没有打注解
记得在这里面打上service的注解