From f761db3047405a48892f3832c4c11a24eeaad47757a299caef52a1bd4007394d Mon Sep 17 00:00:00 2001 From: attiya <2413103649@qq.com> Date: Thu, 25 Dec 2025 16:57:00 +0800 Subject: [PATCH] =?UTF-8?q?sql=E4=BF=AE=E5=A4=8D=E3=80=81=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/cdzy/gather/mqtt/MqttConnectionPool.java | 12 +++++++----- .../main/resources/mapper/EbikeRegionMapper.xml | 16 ++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/ebike-gather/src/main/java/org/cdzy/gather/mqtt/MqttConnectionPool.java b/ebike-gather/src/main/java/org/cdzy/gather/mqtt/MqttConnectionPool.java index 55f3af7..978f83d 100644 --- a/ebike-gather/src/main/java/org/cdzy/gather/mqtt/MqttConnectionPool.java +++ b/ebike-gather/src/main/java/org/cdzy/gather/mqtt/MqttConnectionPool.java @@ -46,16 +46,18 @@ public class MqttConnectionPool implements DisposableBean, InitializingBean { config.setMinIdle(MqttConfig.getPoolMinIdle()); config.setBlockWhenExhausted(true); // 必须设置为 true - config.setMaxWaitMillis(5000); // 等待5秒,不能无限等待 + config.setMaxWaitMillis(5000); // 等待5秒,不能无限等待 + // 禁用空闲连接维护 +// config.setTimeBetweenEvictionRuns(Duration.ofMillis(-1)); // 启用空闲连接维护 config.setTimeBetweenEvictionRuns(Duration.ofMinutes(5)); - config.setSoftMinEvictableIdleTime(Duration.ofMinutes(30)); - config.setMinEvictableIdleTime(Duration.ofMinutes(30)); +// config.setSoftMinEvictableIdleTime(Duration.ofMinutes(30)); //开启则会驱逐(定期销毁空闲) +// config.setMinEvictableIdleTime(Duration.ofMinutes(30)); config.setNumTestsPerEvictionRun(-1); - config.setTestOnBorrow(false); - config.setTestOnReturn(false); + config.setTestOnBorrow(true); + config.setTestOnReturn(true); config.setTestWhileIdle(true); // 空闲时验证(保持连接健康) connectionPool = new GenericObjectPool<>(mqttConnectionFactory, config); diff --git a/ebike-operations/src/main/resources/mapper/EbikeRegionMapper.xml b/ebike-operations/src/main/resources/mapper/EbikeRegionMapper.xml index f79a19e..3fc9a46 100644 --- a/ebike-operations/src/main/resources/mapper/EbikeRegionMapper.xml +++ b/ebike-operations/src/main/resources/mapper/EbikeRegionMapper.xml @@ -21,16 +21,12 @@