From 0536ca3a4bde43a3a99eb2f8dfe5f9c1f81f1a19 Mon Sep 17 00:00:00 2001 From: dftre <3066417822@qq.com> Date: Wed, 11 Sep 2024 16:50:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E8=A6=81=E4=BF=AE=E5=A4=8D=EF=BC=8C?= =?UTF-8?q?=E5=85=B3=E4=BA=8E=E5=9B=A0=E4=B8=BA=E5=88=86=E5=B8=83=E5=BC=8F?= =?UTF-8?q?=E4=BA=8B=E5=8A=A1=E4=B8=8Edruid=E5=85=BC=E5=AE=B9=E6=80=A7?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=AF=BC=E8=87=B4=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E7=9A=84bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/DynamicDataSourceProperties.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DynamicDataSourceProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DynamicDataSourceProperties.java index 695b0c6..ff88049 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DynamicDataSourceProperties.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DynamicDataSourceProperties.java @@ -37,14 +37,10 @@ public class DynamicDataSourceProperties implements InitializingBean { dataSource.setConnectProperties(prop); AtomikosDataSourceBean ds = new AtomikosDataSourceBean(); ds.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource"); - // 添加连接池限制 - ds.setMaxPoolSize(10); - ds.setMinPoolSize(3); - ds.setBorrowConnectionTimeout(60); ds.setUniqueResourceName(name); ds.setXaProperties(prop); - setProperties(dataSource, prop); ds.setXaDataSource(dataSource); + setProperties(dataSource, prop); return ds; } @@ -72,37 +68,38 @@ public class DynamicDataSourceProperties implements InitializingBean { dataSource.setUrl(prop.getProperty("url")); dataSource.setUsername(prop.getProperty("username")); dataSource.setPassword(prop.getProperty("password")); - if(prop.getProperty("initialSize") != null){ + if (prop.getProperty("initialSize") != null) { dataSource.setInitialSize(Integer.parseInt(prop.getProperty("initialSize"))); } - if(prop.getProperty("minIdle") != null){ + if (prop.getProperty("minIdle") != null) { dataSource.setMinIdle(Integer.parseInt(prop.getProperty("minIdle"))); } - if(prop.getProperty("maxActive") != null){ + if (prop.getProperty("maxActive") != null) { dataSource.setMaxActive(Integer.parseInt(prop.getProperty("maxActive"))); } - if(prop.getProperty("maxWait") != null){ + if (prop.getProperty("maxWait") != null) { dataSource.setMaxWait(Long.parseLong(prop.getProperty("maxWait"))); } - if(prop.getProperty("timeBetweenEvictionRunsMillis") != null){ - dataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(prop.getProperty("timeBetweenEvictionRunsMillis"))); + if (prop.getProperty("timeBetweenEvictionRunsMillis") != null) { + dataSource.setTimeBetweenEvictionRunsMillis( + Long.parseLong(prop.getProperty("timeBetweenEvictionRunsMillis"))); } - if(prop.getProperty("minEvictableIdleTimeMillis") != null){ + if (prop.getProperty("minEvictableIdleTimeMillis") != null) { dataSource.setMinEvictableIdleTimeMillis(Long.parseLong(prop.getProperty("minEvictableIdleTimeMillis"))); } - if(prop.getProperty("maxEvictableIdleTimeMillis") != null){ + if (prop.getProperty("maxEvictableIdleTimeMillis") != null) { dataSource.setMaxEvictableIdleTimeMillis(Long.parseLong(prop.getProperty("maxEvictableIdleTimeMillis"))); } - if(prop.getProperty("validationQuery") != null){ + if (prop.getProperty("validationQuery") != null) { dataSource.setValidationQuery(prop.getProperty("validationQuery")); } - if(prop.getProperty("testWhileIdle") != null){ + if (prop.getProperty("testWhileIdle") != null) { dataSource.setTestWhileIdle(Boolean.parseBoolean(prop.getProperty("testWhileIdle"))); } - if(prop.getProperty("testOnBorrow") != null){ + if (prop.getProperty("testOnBorrow") != null) { dataSource.setTestOnBorrow(Boolean.parseBoolean(prop.getProperty("testOnBorrow"))); } - if(prop.getProperty("testOnReturn") != null){ + if (prop.getProperty("testOnReturn") != null) { dataSource.setTestOnReturn(Boolean.parseBoolean(prop.getProperty("testOnReturn"))); } }