BeeCP-Starter是小蜜蜂连接池在Springboot上的启动器
相关功能
1:文件方式配置数据源信息
2:支持多数据源配置
3:可通过自定义的方式支持其他数据源
4:支持配置Jndi数据源引入配置
运行依赖
1:Java版本:JDK1.8
2:Springboot版本:2.0.9.RELEASE
3:BeeCP版本:2.4.7
版本下载
<dependency>
<groupId>com.github.chris2018998</groupId>
<artifactId>spring-boot-starter-beecp</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
单数据源范例
application.properties
spring.datasource.type=cn.beecp.BeeDataSource
spring.datasource.poolName=BeeCP1
spring.datasource.username=root
spring.datasource.password=
spring.datasource.jdbcUrl=jdbc:mysql://localhost:3306/test
spring.datasource.driverClassName=com.mysql.jdbc.Driver
IOC
多数据源范例
application.properties
spring.datasource.nameList=d1,d2,d3
spring.datasource.d1.primary=true
spring.datasource.d1.poolName=BeeCP1
spring.datasource.d1.username=root
spring.datasource.d1.password=root
spring.datasource.d1.jdbcUrl=jdbc:mysql://localhost:3306/test
spring.datasource.d1.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.d2.jndiName=testDB
spring.datasource.d3.poolName=testDB
spring.datasource.d3.datasourceType=com.xxx.xxxDataSource
spring.datasource.d3.datasourceAttributeSetFactory=xxxx
spring.datasource.d3.username=root
spring.datasource.d3.password=root
spring.datasource.d3.jdbcUrl=jdbc:mysql://localhost:3306/test
spring.datasource.d3.driverClassName=com.mysql.cj.jdbc.Driver
DemoApplication.java
@EnableMultiDataSource
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
扩展接口
public interface DataSourceAttributeSetFactory {
public void set(DataSource ds,String configPrefix,Environment environment)throws Exception;
}
|