xinwei #46

Merged
root merged 10 commits from xinwei into master 2024-08-28 09:48:36 +08:00
Showing only changes of commit 514a14df8c - Show all commits

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