1.依赖包
spring-boot-starter-jdbc
or spring-boot-starter-data-jpa
mysql-connector-java
2.连接池
默认优先级:
hikariCP >tomcat pool >commons dbcp2
指定:spring.datasource.type
2.配置项
spring.datasource.url=jdbc:mysql://localhost/test spring.datasource.username=dbuser spring.datasource.password=dbpass spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.drive-class-name可以不配有默认值(会根据url推测),但是mysql6.0以上是com.mysql.cj.jdbc.Driver