2017-09-06 207 views
0

系统提示出现无法启动服务器时无法连接的错误。我想知道为什么它试图寻找192.168.100.16而不是使用localhostZuul服务器运行应用程序

我试着运行应用程序使用-Djava.net.preferIPv4Stack = true,但这也没有工作。

application.yml

server: 
    port: 9090 

# remove that settings in production 
management.security.enabled: false 

eureka: 
    client: 
    serviceUrl: 
     defaultZone: http://127.0.0.1:8761/eureka/ 

zuul: 
    #Service will be mapped under the /api URI 
    prefix: /api 
# Uncomment to disable auto-registering all services read from Eureka 
# ignoredServices: '*' 
    routes: 
    test: 
     path: /redirect/** 
     url: http://google.com 
    customer-by-address: 
     path: /customer-by-address/** 
     url: http://localhost:9098 
    customer-by-service: 
     path: /customer-by-service/** 
     serviceId: CUSTOMER-SERVICE 
    static: 
     path: /static/** 

spring: 
    application: 
    name: zuul-server 

netstat的-tulpn

[email protected] ~ $ netstat -tulpn 
(Not all processes could be identified, non-owned process info 
will not be shown, you would have to be root to see it all.) 
Active Internet connections (only servers) 
Proto Recv-Q Send-Q Local Address   Foreign Address   State  PID/Program name 
tcp  0  0 127.0.0.1:44907   0.0.0.0:*    LISTEN  1969/java  
tcp  0  0 127.0.0.1:63342   0.0.0.0:*    LISTEN  1969/java  
tcp  0  0 0.0.0.0:49841   0.0.0.0:*    LISTEN  1969/java  
tcp  0  0 127.0.1.1:53   0.0.0.0:*    LISTEN  -    
tcp  0  0 0.0.0.0:43927   0.0.0.0:*    LISTEN  1969/java  
tcp  0  0 127.0.0.1:631   0.0.0.0:*    LISTEN  -    
tcp  0  0 127.0.0.1:46137   0.0.0.0:*    LISTEN  1969/java  
tcp  0  0 127.0.0.1:6942   0.0.0.0:*    LISTEN  1969/java  
tcp6  0  0 :::44811    :::*     LISTEN  2210/java  
tcp6  0  0 :::36911    :::*     LISTEN  3671/java  
tcp6  0  0 :::46165    :::*     LISTEN  3671/java  
tcp6  0  0 :::41591    :::*     LISTEN  3671/java  
tcp6  0  0 ::1:631     :::*     LISTEN  -    
tcp6  0  0 :::65336    :::*     LISTEN  2210/java  
tcp6  0  0 :::9090     :::*     LISTEN  3671/java  
udp  0  0 0.0.0.0:38293   0.0.0.0:*       -    
udp  0  0 127.0.1.1:53   0.0.0.0:*       -    
udp  0  0 0.0.0.0:68    0.0.0.0:*       -    
udp  0  0 192.168.100.12:123  0.0.0.0:*       -    
udp  0  0 127.0.0.1:123   0.0.0.0:*       -    
udp  0  0 0.0.0.0:123    0.0.0.0:*       -    
udp  0  0 0.0.0.0:631    0.0.0.0:*       -    
udp  0  0 0.0.0.0:50096   0.0.0.0:*       -    
udp  0  0 0.0.0.0:5353   0.0.0.0:*       -    
udp6  0  0 fe80::3468:6113:b62:123 :::*        -    
udp6  0  0 ::1:123     :::*        -    
udp6  0  0 :::123     :::*        -    
udp6  0  0 :::44987    :::*        -    
udp6  0  0 :::5353     :::*        - 

我有这样的错误

2017-09-05 10:49:35.310 WARN 3671 --- [nfoReplicator-0] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failed with message: java.net.ConnectException: Connection refused (Connection refused) 
2017-09-05 10:49:35.310 WARN 3671 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_ZUUL-SERVER/192.168.100.12:zuul-server:9090 - registration failed Cannot execute request on any known server 

回答

1

Zuul试图与尤里卡沟通,获取列表的在路由请求时使用的服务。但是,netstat输出不会显示任何在端口8761上侦听的进程,这是您的配置表明Eureka应该在的端口。

1

正如Faron所说,您的Zuul实例正尝试连接到一台尤里卡服务器。 您可以从您的application.yml删除此

eureka: 
    client: 
    serviceUrl: 
     defaultZone: http://127.0.0.1:8761/eureka/ 

或启动尤里卡(特别是因为你有一个serviceId部分航线)

如果你想拥有的zuul与尤里卡一个例子,这是一个很好的资源。 Creating microservice using Spring Cloud, Eureka and Zuul

相关问题