feat(launcher): 添加Nacos配置启用控制

This commit is contained in:
黄斌峰
2026-08-07 18:57:28 +08:00
parent cd82edbaf6
commit 1e1a817081
@@ -27,6 +27,7 @@ package org.springblade.common.launch;
import org.springblade.common.constant.LauncherConstant; import org.springblade.common.constant.LauncherConstant;
import org.springblade.core.auto.service.AutoService; import org.springblade.core.auto.service.AutoService;
import org.springblade.core.launch.BladeApplication;
import org.springblade.core.launch.service.LauncherService; import org.springblade.core.launch.service.LauncherService;
import org.springblade.core.launch.utils.PropsUtil; import org.springblade.core.launch.utils.PropsUtil;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
@@ -45,14 +46,17 @@ public class LauncherServiceImpl implements LauncherService {
public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) { public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) {
Properties props = System.getProperties(); Properties props = System.getProperties();
// nacos注册中心配置 if (BladeApplication.isNacosConfigEnabled()) {
PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.username", LauncherConstant.NACOS_USERNAME); // nacos注册中心配置
PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.password", LauncherConstant.NACOS_PASSWORD); PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.username", LauncherConstant.NACOS_USERNAME);
PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.server-addr", LauncherConstant.nacosAddr(profile)); PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.password", LauncherConstant.NACOS_PASSWORD);
// nacos配置中心配置 PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.server-addr", LauncherConstant.nacosAddr(profile));
PropsUtil.setProperty(props, "spring.cloud.nacos.config.username", LauncherConstant.NACOS_USERNAME); // nacos配置中心配置
PropsUtil.setProperty(props, "spring.cloud.nacos.config.password", LauncherConstant.NACOS_PASSWORD); PropsUtil.setProperty(props, "spring.cloud.nacos.config.username", LauncherConstant.NACOS_USERNAME);
PropsUtil.setProperty(props, "spring.cloud.nacos.config.server-addr", LauncherConstant.nacosAddr(profile)); PropsUtil.setProperty(props, "spring.cloud.nacos.config.password", LauncherConstant.NACOS_PASSWORD);
PropsUtil.setProperty(props, "spring.cloud.nacos.config.server-addr", LauncherConstant.nacosAddr(profile));
}
// sentinel配置 // sentinel配置
PropsUtil.setProperty(props, "spring.cloud.sentinel.transport.dashboard", LauncherConstant.sentinelAddr(profile)); PropsUtil.setProperty(props, "spring.cloud.sentinel.transport.dashboard", LauncherConstant.sentinelAddr(profile));
// 多数据源配置 // 多数据源配置