深蓝色的风 2015-07-15 13:40 采纳率: 0%
浏览 3884

@Service注入无效,但是通过Controller进来的可以成功,这是为啥?

spring MVC+Spring+Mybatis的架构
我的扫描配置如下:

 <context:component-scan base-package="com.pp.susf">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
    </context:component-scan>
在一个类中使用如下注解注入不可行:
@Autowired
private ITestService testService;

而在Controller中
    @Autowired
private ITestService testService;
则调用正常
  • 写回答

4条回答 默认 最新

  • 丵鹰 2015-07-15 15:53
    关注

    是不是你的类上没有写注解@Service

    评论

报告相同问题?

悬赏问题

  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?