提交 6bf64f55 编写于 作者: sq3536's avatar sq3536

model

上级 065bc20e
...@@ -7,11 +7,11 @@ spring: ...@@ -7,11 +7,11 @@ spring:
cloud: cloud:
nacos: nacos:
discovery: discovery:
server-addr: 192.168.3.23:8848 server-addr: 172.16.100.77:8848
datasource: datasource:
username: root username: root
password: root password: root
defaultSchema: a_A_5d9d78509 defaultSchema: a_A_5d9d78509
url: jdbc:mysql://192.168.3.23:3306/a_A_5d9d78509?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true url: jdbc:mysql://172.16.100.77:3306/a_A_5d9d78509?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true
redis: redis:
host: 192.168.3.23 host: 172.16.100.77
\ No newline at end of file \ No newline at end of file
...@@ -48,6 +48,8 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl { ...@@ -48,6 +48,8 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
{ {
synchronized (lock) synchronized (lock)
{ {
if (check.containsKey(dstDataSource.getDsName()))
return super.buildDS(dstDataSource);
DataSourceProperty dataSourceProperty = new DataSourceProperty(); DataSourceProperty dataSourceProperty = new DataSourceProperty();
DynamicRoutingDataSource ds = dataSource; DynamicRoutingDataSource ds = dataSource;
List<Setting> settings = JSONArray.parseArray(dstDataSource.getDsCfg(), Setting.class); List<Setting> settings = JSONArray.parseArray(dstDataSource.getDsCfg(), Setting.class);
...@@ -64,7 +66,9 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl { ...@@ -64,7 +66,9 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
else if (setting.getProperty().equalsIgnoreCase("defaultSchema")) else if (setting.getProperty().equalsIgnoreCase("defaultSchema"))
dataSourceProperty.setSchema(setting.getValue()); dataSourceProperty.setSchema(setting.getValue());
} }
DataSource dataSource = BasicDataSourceCreator.getInstance().createDataSource(dataSourceProperty);
dataSourceProperty.getDruid().setFilters("stat,log4j2");
DataSource dataSource = druidDataSourceCreator.createDataSource(dataSourceProperty);
ds.addDataSource(dstDataSource.getDsName(), dataSource); ds.addDataSource(dstDataSource.getDsName(), dataSource);
check.put(dstDataSource.getDsName(), 1); check.put(dstDataSource.getDsName(), 1);
...@@ -80,7 +84,7 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl { ...@@ -80,7 +84,7 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
@Autowired @Autowired
@Lazy @Lazy
private DruidDataSourceCreator druidDataSourceCreator; private DataSourceCreator druidDataSourceCreator;
private HashMap<String,Integer> check=new HashMap<>(); private HashMap<String,Integer> check=new HashMap<>();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册