1.在pom.xml文件中引入依赖
<dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper</artifactId> <version>3.3.7</version> </dependency> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> </dependency>
2.在spring的dao层配置中进行配置,将原本的配置扫描Dao接口包进行如下修改。
修改前:
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> <property name="basePackage" value="com.zxh.dao"></property> </bean>
修改后:
<bean class="tk.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> <property name="basePackage" value="com.zxh.dao"></property> </bean>
对于其他的数据操作可参考https://www.cnblogs.com/zys2019/p/13196320.html。