-- 配置hikari的数据库配置
datasource:
hikari:
minimum-idle: 100
jdbc-url: jdbc:mysql://192.168.120.134:3306/event?useUnicode=true&autoReconnect=true&rewriteBatchedStatements=TRUE
password: 123456
username: root
type: com.zaxxer.hikari.HikariDataSource
-- 自己配置hik数据源的配置,提前初始化连接池,默认的是使用的时候才使用连接池
@Configuration
public class HikDataSourceConfig {
@Bean
@ConfigurationProperties(prefix = "spring.datasource.hikari")
public HikariConfig hikariConfig(){
return new HikariConfig();
}
@Bean
public HikariDataSource dataSource() {
return new HikariDataSource(hikariConfig());
}
}