异常org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProces

异常org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588

org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588

关于这个异常信息:在刚刚搭建SSM框架的时候 如果你出现了这个异常
那么首先检查:
1.ServiceImpl 文件 @Service 注解
注入Dao层 @Autowired 注解

2.检查一下扫包` spring-mvc.xml 文件

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

3.文件spring-mybatis.xml 最重要的一步,我测试好几次了如果这步配置路径错误的会一直报这个错误。
mapper文件一定要在resources 文件下面 ,亲测 不然一直报错。
这是正确路径,

<!-- 配置SqlSessionFactory对象 -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <!-- 注入数据库连接池 -->
        <property name="dataSource" ref="dataSource"/>
        <!-- 扫描model包 使用别名 -->
        <property name="typeAliasesPackage" value="com.ssm.entity"/>
        <!-- 扫描sql配置文件:mapper需要的xml文件 -->
        <property name="mapperLocations" value="classpath:mapper/*.xml"/>
<!--        <property name="mapperLocations" value="mapper/*.xml"/>-->
    </bean>

扫描mapper路径:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值