1.轻车熟路,面向百度编程,搜索SpringBoot Mybatis,看到有个官方网站,进入
看到了目前最新的版本,2.1以及下面maven的依赖,美滋滋的放到自己的pom.xml
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>


2.这时候我们发现项目中需要一个datasource的连接池,和连接账户,密码的问题。
打开Spring官网找到SpringBoot分区,进入docs。
可以看到官网说,我们提供了一个HikanCP的高性能高并发的连接池,只要你用的是
spring-boot-starter-jdbc 或者 spring-boot-starter-data-jpa,我们就给你这个连接池的依赖。
OK,Let's go! 直接copy代码到我们的application.properties,改成自己的。
spring.datasource.url=jdbc:mysql://localhost/test
spring.datasource.username=dbuser
spring.datasource.password=dbpass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
别忘了,在pom.xml添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
到目前为止,我们完成了Spring datasource的一个配置

网友评论