1.前言
Springboot最近可谓是非常的火,本人也在项目中尝到了甜头。之前一直使用Springboot+JPA,用了一段时间发现JPA不是太灵活,也有可能是我不精通JPA,总之为了多学学Springboot我决定尝试一下Springboot+MyBatis+JPA三项集成,集成过程中遇到了很多问题,但最后总算是集成成功了,现在记录一下方法。
1.1 如何使用MyBatis Generator自动生成xxxMapper.java接口以及xxxMapper.xml文件
以前用过SpringMVC,知道写xxxMapper.java接口以及xxxMapper.xml文件的辛苦,这次集成最先想到的就是先解决如何使用如何使用MyBatis Generator自动生成这些文件的问题。
先扔出MyBatis Generator的官网->请戳这里
我使用的Maven集成插件的方式,IDE使用的是IDEA
1.1.1 创建项目
20180126110629.png
20180126110757.png
20180126110812.png
1.1.2 修改pom.xml
添加了Druid依赖和MyBatis Generator插件
其他依赖请自行添加
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.study.springboot
mybatis
1.0
war
demo
springboot+mybatis+jpa
org.springframework.boot
spring-boot-starter-parent
1.5.9.RELEASE
UTF-8
UTF-8
1.8
org.springframework.boot
spring-boot-starter-data-jpa
org.mybatis.spring.boot
mybatis-spring-boot-starter
1.3.1
org.springframework.boot
spring-boot-starter-web
mysql
mysql-connector-java
runtime
org.springframework.boot
spring-boot-starter-tomcat
or