From 514a14df8c97417a079e68a67cd6a3d331145a40 Mon Sep 17 00:00:00 2001 From: XinWei <2718030729@qq.com> Date: Wed, 28 Aug 2024 09:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=84=E5=BB=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/nacos/config/BeanInit.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/framework/nacos/config/BeanInit.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/framework/nacos/config/BeanInit.java index dd9f3569f..5b4c0fae6 100644 --- a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/framework/nacos/config/BeanInit.java +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/framework/nacos/config/BeanInit.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.datacenter.framework.nacos.config; import com.alibaba.cloud.nacos.NacosDiscoveryProperties; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; @@ -13,15 +14,19 @@ public class BeanInit { /** * 用于改变程序自动获取的本机ip */ + @Value("${spring.profiles.active}") + private String activeEnv; @Bean @Primary public NacosDiscoveryProperties nacosProperties() throws UnknownHostException { NacosDiscoveryProperties nacosDiscoveryProperties = new NacosDiscoveryProperties(); - // 直接指定域名 - String customIp = "120.46.37.243"; // 替换为你的域名 - int customPort = 9091; // 替换为你的端口 - nacosDiscoveryProperties.setIp(customIp ); - nacosDiscoveryProperties.setPort(customPort); + if ("dev".equals(activeEnv)){ + // 直接指定域名 + String customIp = "120.46.37.243"; // 替换为你的域名 + int customPort = 9091; // 替换为你的端口 + nacosDiscoveryProperties.setIp(customIp); + nacosDiscoveryProperties.setPort(customPort); + } return nacosDiscoveryProperties; } }