报错类型:Error creating bean with name ‘indexJspController’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wg.blog.service.UpvoteService com.wg.blog.controller.IndexJspController.upvoteService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.wg.blog.service.UpvoteService] 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)}
可能原因:
1.spring-mvc配置文件错误,是否对所建的包进行了扫描
2.mapper.xml文件的命名空间namespace是否跟mapper文件的路径一致;
3.若确定没有以上错误,可以查看编译是否出错,在classes文件中查看自己的配置文件是否编译成功。若为编译出错在项目的pom.xml文件中加入以下代码即可