|
@@ -34,6 +34,7 @@ import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
+import java.net.InetAddress;
|
|
|
|
|
|
@SpringBootApplication(exclude = {
|
|
|
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
|
|
@@ -61,9 +62,22 @@ public class DavinciServerApplication {
|
|
|
@PostConstruct
|
|
|
public void registerInstance() throws NacosException
|
|
|
{
|
|
|
- if(CollectionUtils.isEmpty(namingService.getAllInstances(applicationName))){
|
|
|
- namingService.registerInstance(applicationName,serverAddress,serverPort);
|
|
|
+ InetAddress ia=null;
|
|
|
+ try {
|
|
|
+ ia= InetAddress.getLocalHost();
|
|
|
+
|
|
|
+ String localname=ia.getHostName();
|
|
|
+ String localip=ia.getHostAddress();
|
|
|
+ if(CollectionUtils.isEmpty(namingService.getAllInstances(applicationName))){
|
|
|
+ namingService.registerInstance(applicationName,localip,serverPort);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|