qq_31316239 2017-09-03 08:47 采纳率: 0%
浏览 2004

使用SpringMVC+Mybatis时,无法注入service

spring-mvc.xml中如下:



/context:component-scan
我明明扫描了所有的包为什么还是找不到,出现如下异常:

九月 03, 2017 4:41:52 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Allocate exception for servlet spring
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.lyj.bookmanage.service.IUserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}

这是service
这是controller

  • 写回答

5条回答 默认 最新

  • 砸死接触 2017-09-03 09:01
    关注

    @resource默认按照名称进行装配,Dao层的那个没贴就不说了,但是你的UserServiceImpl示例化后应该是userServiceImpl啊,哪有userService?

    @service注解时,默认别名就是当前类名,但是首字母小写,如果要定义别名用@service('userService')形式!

    评论

报告相同问题?