Springboot2.0之後,只有Druid1.1.10以上的版本才能支持:
pom.xml
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.21</version>
</dependency>
application.properities
###########數據庫配置##########
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
##開發用
spring.datasource.url=jdbc:mysql://1.1.1.1:3306/baoyandao?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
##部署用
#spring.datasource.url=jdbc:mysql://1.1.1.1:3306/baoyandao?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.username=111
spring.datasource.password=111
#druid
spring.datasource.druid.initial-size=10
spring.datasource.druid.min-idle=10
spring.datasource.druid.maxActive=20
s