Bee实现了几种简单的数据源,用于开发/测试;
生产上一般都是选用性能比较好的数据源工具,Bee内置实现的,主要是为了方便开发/测试;
1.
SimpleDataSource
参考:
参考bee-exam工程,I
nitSameDsUtil.DruidDataSource dataSource0; //只是测试,在开发/测试阶段,不想引入 DruidDataSource也可以换成SimpleDataSource
DruidDataSource dataSource0; //只是测试,在开发/测试阶段,不想引入DruidDataSource也可以换成SimpleDataSourcedataSource0 = new DruidDataSource();dataSource0.setUrl("jdbc:mysql://localhost:3306/bee?characterEncoding=UTF-8&useSSL=false");dataSource0.setUsername("root");dataSource0.setPassword("123456");
2. MongoDB,内置的数据源支持:
MongodbSimpleDataSource dataSource0=new MongodbSimpleDataSource("mongodb://localhost:27017/bee","","");
参考bee-exam工程,InitOtherDsAndMongoDsUtil
3. bee-spring boot 整合了相关的数据源
DataSourceToolRegHandler:// #bee.db.dbs[i].type value :Hikari,Druid,c3p0,dbcp2,Tomcat,BeeMongo,BeeSimpleDs default is : Hikaripublic static void init() {DataSourceBuilderFactory.register("Hikari", new HikariDataSourceBuilder());DataSourceBuilderFactory.register("Druid", new DruidDataSourceBuilder());DataSourceBuilderFactory.register("Dbcp2", new Dbcp2DataSourceBuilder());DataSourceBuilderFactory.register("C3p0", new C3p0DataSourceBuilder());DataSourceBuilderFactory.register("Tomcat", new TomcatDataSourceBuilder());DataSourceBuilderFactory.register("BeeSimpleDs", new BeeSimpleDataSourceBuilder()); //V2.1.8}BeeMongodbRegHandler:public static void init() {DataSourceBuilderFactory.register("BeeMongo", new BeeMongodbSimpleDataSourceBuilder());}
在配置多数据源时,可指定#bee.db.dbs[0].type=Druid
#bee.db.dbs[0].type=Druid
#bee.db.dbs[0].dsName=ds0
#bee.db.dbs[0].driverClassName = com.mysql.jdbc.Driver
#bee.db.dbs[0].url =jdbc:mysql://localhost:3306/bee?characterEncoding=UTF-8&useSSL=false
#bee.db.dbs[0].username = root
#bee.db.dbs[0].password =123456#bee.db.dbs[1].type=Druid
#bee.db.dbs[1].url =jdbc:mysql://localhost:3306/pro?characterEncoding=UTF-8&useSSL=false
#bee.db.dbs[1].username = root
#bee.db.dbs[1].password =123456