本章学习目标:
mybatis整合spring,没有Mapper实现类
本片博文在上篇的基础上进行改造https://blog.csdn.net/weixin_45493345/article/details/103930960
删除实现类
修改applicationContext.xml
<!-- 创建UserMapperImpl对象,注入sqlsessionFactory -->
<bean id="userMapper" class="com.imooc.dao.impl.UserMapperImpl">
<!-- 注入sqlsessionFactory -->
<property name="sqlSessionFactory" ref="sqlSessionFactory"/>
</bean>
讲解:我们上面删除了实现类,因此这个配置也可以一并删除,按照下面进行修改
<!-- 配置Mapper接口 -->
<bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
<!-- 关联Mapper接口 -->
<property name="mapperInterface" value="com.imooc.dao.UserMapper"/>
<!-- 关联SqlSessionFactory -->
<property name="sqlSessionFactory" ref="sqlSessionFactory"/>
</bean>