1.pom.xml中添加mybatis依赖
2.application.properties中添加数据源配置
3.反向生成dao的代码
1.
<!-- mybatis-spring-boot-starter -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
<!-- MySQL的jdbc驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
添加xml和properties的编译配置
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
2.
spring.datasource.url=url
spring.datasource.username=uat
spring.datasource.password=uat
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
3.自动生成mapper代码-见文章
pom中添加配置然后添加自定义生成mapper的类:
<!-- mybatis-generator -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency>
如果是从其他项目拷贝进来的,注意此处需要更改为正确的项目地址:
标签:集成,springboot,spring,dependency,添加,datasource,mybatis From: https://www.cnblogs.com/healthinfo/p/17238820.html