Discuss / Java / 第三方bean

第三方bean

Topic source

净净一隅

#1 Created at ... [Delete] [Delete and Lock User]

@Bean
DataSource createDataSource() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://localhost:3306/learnjdbc?useUnicode=true&characterEncoding=utf-8");
config.setUsername("root");
config.setPassword("123456");
config.addDataSourceProperty("connectionTimeout", "10000"); // 连接超时:1秒
config.addDataSourceProperty("idleTimeout", "60000"); // 空闲超时:60秒
config.addDataSourceProperty("maximumPoolSize", "10"); // 最大连接数:10
config.addDataSourceProperty("autoCommit", "true"); // 最大连接数:10
DataSource ds = new HikariDataSource(config);
return ds;
}


  • 1

Reply