mirror of
https://gitee.com/nutz/nutzboot.git
synced 2024-11-29 18:28:01 +08:00
...
This commit is contained in:
parent
210ccf710d
commit
3c035f4104
@ -200,21 +200,26 @@ public class NutDaoStarter {
|
||||
Matcher match = pattern.matcher(key);
|
||||
if(match.find()) {
|
||||
// 获取数据库名称
|
||||
String name = match.group(1);
|
||||
String prefix_name = "jdbc.many." + name + ".";
|
||||
DataSource manyDataSource = DataSourceStarter.createDataSource(ioc, conf, prefix_name);
|
||||
NutDao nutDao = new NutDao();
|
||||
nutDao.setDataSource(manyDataSource);
|
||||
// 处理对应的从库
|
||||
String slave_prefix = prefix_name + "slave.";
|
||||
DataSource slaveDataSource = DataSourceStarter.getManySlaveDataSource(ioc, conf, slave_prefix);
|
||||
if(slaveDataSource != null) {
|
||||
NutDaoRunner runner = new NutDaoRunner();
|
||||
runner.setSlaveDataSource(slaveDataSource);
|
||||
nutDao.setRunner(runner);
|
||||
try {
|
||||
String name = match.group(1);
|
||||
String prefix_name = "jdbc.many." + name + ".";
|
||||
DataSource manyDataSource = DataSourceStarter.createSlaveDataSource(ioc, conf, prefix_name);
|
||||
NutDao nutDao = new NutDao();
|
||||
nutDao.setDataSource(manyDataSource);
|
||||
// 处理对应的从库
|
||||
String slave_prefix = prefix_name + "slave.";
|
||||
DataSource slaveDataSource = DataSourceStarter.getManySlaveDataSource(ioc, conf, slave_prefix);
|
||||
if(slaveDataSource != null) {
|
||||
NutDaoRunner runner = new NutDaoRunner();
|
||||
runner.setSlaveDataSource(slaveDataSource);
|
||||
nutDao.setRunner(runner);
|
||||
}
|
||||
// 加入到ioc对象
|
||||
ioc.addBean(name + "Dao", nutDao);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("datasource init error "+prefix_name, e);
|
||||
}
|
||||
// 加入到ioc对象
|
||||
ioc.addBean(name + "Dao", nutDao);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user