From a1b8e34b4f435d448f86b5c6c2a68252fafb9741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Tue, 27 Oct 2026 10:41:39 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E5=B1=8F?= =?UTF-8?q?=E8=94=BD=E4=B8=80=E4=BA=9B=E6=97=A0=E7=94=A8warn=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DynamicDataSourceEndpoint.java | 88 +++++++++++++++++++ .../src/main/resources/application.yml | 2 + .../src/main/resources/logback-plus.xml | 2 + 3 files changed, 92 insertions(+) create mode 100644 ruoyi-admin/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DynamicDataSourceEndpoint.java diff --git a/ruoyi-admin/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DynamicDataSourceEndpoint.java b/ruoyi-admin/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DynamicDataSourceEndpoint.java new file mode 100644 index 000000000..8d8ab615a --- /dev/null +++ b/ruoyi-admin/src/main/java/com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DynamicDataSourceEndpoint.java @@ -0,0 +1,88 @@ +/* + * Copyright © 2018 organization baomidou + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.baomidou.dynamic.datasource.spring.boot.autoconfigure; + +import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; +import com.baomidou.dynamic.datasource.ds.GroupDataSource; +import com.baomidou.dynamic.datasource.ds.ItemDataSource; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.boot.actuate.endpoint.annotation.Endpoint; +import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; + +import javax.sql.DataSource; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * 只读运维端点:暴露当前所有数据源(含运行期动态增删的)、分组构成与全局开关状态, + * 访问路径 {@code /actuator/dynamicDatasource}(需按 actuator 惯例显式暴露)。 + *
+ * 刻意不返回 URL / 用户名等连接串信息——URL 可能携带凭据,状态盘点不需要它们。
+ */
+@Endpoint(id = "dynamicDatasource")
+public class DynamicDataSourceEndpoint {
+
+ private final ObjectProvider