转载出处:https://blog.csdn.net/weixin_41868360/article/details/81240353

错误如下:

maven搭建的ssm框架:报错org.springframework.beans.factory.UnsatisfiedDependencyException

解决方案如下:

1) service接口实现类上有没有加@Service注解,注解是不是引用的spring的类?不要导错包

2) 接口有没有写实现类,实现类是实现的对应接口么?比如CategoryServiceImpl implementsCategoryDAO 一不小心根据自动提示,本来应该实现CategoryService,结果实现了CategoryDAO

3) 有没有扫描Service所在的包
 

<!-- 启动自动扫描 -->  
    <context:component-scan base-package="com.ssm.blog.*">  
        <!-- 制定扫包规则 ,不扫描@Controller注解的JAVA类 -->  
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>  
    </context:component-scan>

这里的base-package的值是一定要将service接口包含在里面的,

4)确保代码无误后,再看看包是否下载完整

5)查看注入是否正确


      我的问题是第3个没有扫描service所在的包,applicationContext.xml改好之后为

maven搭建的ssm框架:报错org.springframework.beans.factory.UnsatisfiedDependencyException

相关文章:

  • 2021-09-21
  • 2021-11-28
  • 2022-12-23
  • 2021-11-19
  • 2021-11-19
猜你喜欢
  • 2021-05-26
  • 2021-11-18
  • 2021-11-18
  • 2021-11-18
  • 2021-11-15
  • 2021-11-29
相关资源
相似解决方案