com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar:1.19.1]
at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.6.2.jar:1.6.2]
at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.access
200
(
W
e
b
R
e
s
o
u
r
c
e
.
j
a
v
a
:
74
)
[
j
e
r
s
e
y
−
c
l
i
e
n
t
−
1.19.1.
j
a
r
:
1.19.1
]
a
t
c
o
m
.
s
u
n
.
j
e
r
s
e
y
.
a
p
i
.
c
l
i
e
n
t
.
W
e
b
R
e
s
o
u
r
c
e
200(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1] at com.sun.jersey.api.client.WebResource
200(WebResource.java:74) [jersey−client−1.19.1.jar:1.19.1]atcom.sun.jersey.api.client.WebResourceBuilder.post(WebResource.java:570) ~[jersey-client-1.19.1.jar:1.19.1]
at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.register(AbstractJerseyEurekaHttpClient.java:56) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) [eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) [eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) [eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.executeOnNewServer(RedirectingEurekaHttpClient.java:118) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:79) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) [eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) [eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:119) [eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) [eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator
1.
e
x
e
c
u
t
e
(
E
u
r
e
k
a
H
t
t
p
C
l
i
e
n
t
D
e
c
o
r
a
t
o
r
.
j
a
v
a
:
59
)
[
e
u
r
e
k
a
−
c
l
i
e
n
t
−
1.6.2.
j
a
r
:
1.6.2
]
a
t
c
o
m
.
n
e
t
f
l
i
x
.
d
i
s
c
o
v
e
r
y
.
s
h
a
r
e
d
.
t
r
a
n
s
p
o
r
t
.
d
e
c
o
r
a
t
o
r
.
S
e
s
s
i
o
n
e
d
E
u
r
e
k
a
H
t
t
p
C
l
i
e
n
t
.
e
x
e
c
u
t
e
(
S
e
s
s
i
o
n
e
d
E
u
r
e
k
a
H
t
t
p
C
l
i
e
n
t
.
j
a
v
a
:
77
)
[
e
u
r
e
k
a
−
c
l
i
e
n
t
−
1.6.2.
j
a
r
:
1.6.2
]
a
t
c
o
m
.
n
e
t
f
l
i
x
.
d
i
s
c
o
v
e
r
y
.
s
h
a
r
e
d
.
t
r
a
n
s
p
o
r
t
.
d
e
c
o
r
a
t
o
r
.
E
u
r
e
k
a
H
t
t
p
C
l
i
e
n
t
D
e
c
o
r
a
t
o
r
.
r
e
g
i
s
t
e
r
(
E
u
r
e
k
a
H
t
t
p
C
l
i
e
n
t
D
e
c
o
r
a
t
o
r
.
j
a
v
a
:
56
)
[
e
u
r
e
k
a
−
c
l
i
e
n
t
−
1.6.2.
j
a
r
:
1.6.2
]
a
t
c
o
m
.
n
e
t
f
l
i
x
.
d
i
s
c
o
v
e
r
y
.
D
i
s
c
o
v
e
r
y
C
l
i
e
n
t
.
r
e
g
i
s
t
e
r
(
D
i
s
c
o
v
e
r
y
C
l
i
e
n
t
.
j
a
v
a
:
798
)
[
e
u
r
e
k
a
−
c
l
i
e
n
t
−
1.6.2.
j
a
r
:
1.6.2
]
a
t
c
o
m
.
n
e
t
f
l
i
x
.
d
i
s
c
o
v
e
r
y
.
I
n
s
t
a
n
c
e
I
n
f
o
R
e
p
l
i
c
a
t
o
r
.
r
u
n
(
I
n
s
t
a
n
c
e
I
n
f
o
R
e
p
l
i
c
a
t
o
r
.
j
a
v
a
:
104
)
[
e
u
r
e
k
a
−
c
l
i
e
n
t
−
1.6.2.
j
a
r
:
1.6.2
]
a
t
j
a
v
a
.
u
t
i
l
.
c
o
n
c
u
r
r
e
n
t
.
E
x
e
c
u
t
o
r
s
1.execute(EurekaHttpClientDecorator.java:59) [eureka-client-1.6.2.jar:1.6.2] at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) [eureka-client-1.6.2.jar:1.6.2] at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) [eureka-client-1.6.2.jar:1.6.2] at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:798) [eureka-client-1.6.2.jar:1.6.2] at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:104) [eureka-client-1.6.2.jar:1.6.2] at java.util.concurrent.Executors
1.execute(EurekaHttpClientDecorator.java:59)[eureka−client−1.6.2.jar:1.6.2]atcom.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)[eureka−client−1.6.2.jar:1.6.2]atcom.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)[eureka−client−1.6.2.jar:1.6.2]atcom.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:798)[eureka−client−1.6.2.jar:1.6.2]atcom.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:104)[eureka−client−1.6.2.jar:1.6.2]atjava.util.concurrent.ExecutorsRunnableAdapter.call(Executors.java:511) [na:1.8.0_151]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_151]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access
201
(
S
c
h
e
d
u
l
e
d
T
h
r
e
a
d
P
o
o
l
E
x
e
c
u
t
o
r
.
j
a
v
a
:
180
)
[
n
a
:
1.8.
0
1
51
]
a
t
j
a
v
a
.
u
t
i
l
.
c
o
n
c
u
r
r
e
n
t
.
S
c
h
e
d
u
l
e
d
T
h
r
e
a
d
P
o
o
l
E
x
e
c
u
t
o
r
201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_151] at java.util.concurrent.ScheduledThreadPoolExecutor
201(ScheduledThreadPoolExecutor.java:180)[na:1.8.0151]atjava.util.concurrent.ScheduledThreadPoolExecutorScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_151]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_151]
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_151]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_151]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_151]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_151]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_151]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_151]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_151]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_151]
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:134) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.3.jar:4.5.3]
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
… 29 common frames omitted
贴一段eureka服务器端yml配置文件
server:
port: 7001
eureka:
instance:
hostname: localhost #eureka服务端的实例名称
client:
register-with-eureka: false #false表示不向注册中心注册自己。
fetch-registry: false #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka #设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个地址。
贴一段eureka客户端yml配置文件
server:
port: 8001
mybatis:
config-location: classpath:mybatis/mybatis.cfg.xml # mybatis配置文件所在路径
type-aliases-package: cn.jiewen.springboot.entities # 所有Entity别名类所在包
mapper-locations:
- classpath:mybatis/mapper/**/*.xml # mapper映射文件
spring:
application:
name: microservicecloud-dept
datasource:
type: com.alibaba.druid.pool.DruidDataSource # 当前数据源操作类型
driver-class-name: org.gjt.mm.mysql.Driver # mysql驱动包
url: jdbc:mysql://localhost:3306/cloudDB01 # 数据库名称
username: root
password: 123456
dbcp2:
min-idle: 5 # 数据库连接池的最小维持连接数
initial-size: 5 # 初始化连接数
max-total: 5 # 最大连接数
max-wait-millis: 200 # 等待连接获取的最大超时时间
eureka:
client: #客户端注册进eureka服务列表内
service-url:
defaultZone: http://localhost:7001/eureka
注意看客户端的注册
eureka注册前多了制表符,所以导致客服端无法向eureka中心注册
把制表空格删除,问题解决。