一、MySql连接数据库
1、pom依赖
<!--mybatis配置-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
<!--MySQL-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
2、properties配置
#MySql
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://106.12.58.186:3306/learn
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.tomcat.initial-size=10
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-wait=1000
spring.datasource.tomcat.validation-query=select 1 from dual
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.max-idle=100
spring.datasource.tomcat.min-idle=10
spring.datasource.tomcat.testWhileIdle=true
spring.datasource.tomcat.removeAbandoned=true
二、SQLserver连接数据库
1、pom依赖
<!--mybatis配置-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
<!--SqlServer-->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
2、properties配置
# SqlServer
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.url=jdbc:sqlserver://106.12.58.186:1433;databaseName=learn
spring.datasource.username=sa
spring.datasource.password=sa
spring.datasource.tomcat.initial-size=10
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-wait=1000
spring.datasource.tomcat.validation-query=select 1
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.max-idle=100
spring.datasource.tomcat.min-idle=10
spring.datasource.tomcat.testWhileIdle=true
spring.datasource.tomcat.removeAbandoned=true
三、Oracle连接数据库
1、pom依赖
<!--mybatis配置-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
<!--Oracle-->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>12.1.0.2</version>
</dependency>
2、properties配置
# Oracle
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@106.12.58.186:1521/dual
spring.datasource.username=dual
spring.datasource.password=dual
spring.datasource.tomcat.initial-size=10
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-wait=1000
spring.datasource.tomcat.validation-query=select 1 from dual
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.max-idle=100
spring.datasource.tomcat.min-idle=10
spring.datasource.tomcat.testWhileIdle=true
spring.datasource.tomcat.removeAbandoned=true