使用SpringMVC开发中,dao层接口无法在Service层注入,sessionFactory无法再Dao层注入

1、使用Spring开发中,service接口或者是dao层接口无法注入,遇dao到这种情况, 首先检查dao层和service层是否被扫描到
    原因:service层为扫描到
    <!-- 注解扫描包,注意换成自己的路径 -->
    < context:component-scan base-package = "com.hh" use-default-filters = "false" >
        <!-- 扫描Controller的部分 -->
           < context:include-filter type = "annotation" expression = "org.springframework.stereotype.Controller" />
           <!-- 扫描Service的部分 -->
           < context:include-filter type = "annotation" expression = "org.springframework.stereotype.Service" />
           <!-- 扫描 Dao 的部分 -->
           < context:include-filter type = "annotation" expression = "org.springframework.stereotype.Repository" />  
    </ context:component-scan >
2、1不能解决则查看service接口是否有注解标示,或者检查自己写的dao和service对应配置文件中bean ID。
3、检查mybatis是否存在语法错误。




猜你喜欢

转载自blog.csdn.net/hhua5230/article/details/79923781
今日推荐