提交 bf7844c4 编写于 作者: zhouweidong's avatar zhouweidong

项目支持打war包

上级 b4808717
......@@ -47,17 +47,23 @@ public class NacosRegisterConfig implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) {
log.info("正在尝试将应用程序注册到nacos");
if (registration != null && port != null) {
try {
String containerPort = getContainerPort();
if(!StringUtils.isEmpty(containerPort)){
log.info("正在尝试将应用程序注册到nacos,端口号为:{}",containerPort);
registration.setPort(new Integer(containerPort));
registration.start();
if(StringUtils.isEmpty(containerPort)){
log.info("无法获取应用程序端口,将应用程序注册到nacos请求被忽略");
return;
}
registration.setPort(new Integer(containerPort));
registration.start();
} catch (Exception e) {
throw new BadRequestAlertException("应用程序注册到nacos失败,"+e,"","");
}
log.info("已将应用程序成功注册到nacos");
}
else{
log.info("无法获取应用程序端口,将应用程序注册到nacos请求被忽略");
}
}
......
......@@ -60,15 +60,20 @@ public class NacosRegisterConfig implements ApplicationRunner {
if (registration != null && port != null) {
try {
String containerPort = getContainerPort();
if(!StringUtils.isEmpty(containerPort)){
registration.setPort(new Integer(containerPort));
registration.start();
if(StringUtils.isEmpty(containerPort)){
log.info("无法获取应用程序端口,将应用程序注册到nacos请求被忽略");
return;
}
registration.setPort(new Integer(containerPort));
registration.start();
} catch (Exception e) {
throw new BadRequestAlertException("应用程序注册到nacos失败,"+e,"","");
}
log.info("已将应用程序成功注册到nacos");
}
else{
log.info("无法获取应用程序端口,将应用程序注册到nacos请求被忽略");
}
}
/**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册