构建修改

This commit is contained in:
XinWei 2024-08-28 09:45:37 +08:00
parent 5adf95ffd0
commit 514a14df8c

View File

@ -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;
}
}