导入
Pom.xml
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.12</version>
</dependency>
使用
@EnableWebMvc
DruidDataSource dataSource = new DruidDataSource();
try {
dataSource.setDriverClassName(pop.getProperty("jdbc.driver"));
dataSource.setUsername(pop.getProperty("jdbc.username"));
dataSource.setPassword(pop.getProperty("jdbc.password"));
dataSource.setUrl(pop.getProperty("jdbc.url"));
dataSource.setDefaultAutoCommit(true);
dataSource.setMinIdle(0);
dataSource.setMaxActive(10);
dataSource.setName("hikariDataSource in Hikari System");
} catch (Exception e) {
e.printStackTrace();
}
return dataSource;