套接字连接异常,表示连接被拒绝

时间:2016-03-10 08:43:00

标签: java spring maven sockets intellij-idea

我正在构建一个spring boot应用程序,它有一个主服务正在使用的多个微服务。服务创建为maven模块,我在试用期内使用intelliJ IDEA 15。现在,当我尝试运行该服务时,我收到以下错误。我认为我的tomcat服务器没有运行,但我没有得到如何检查,如果这是问题,那么如何解决。我在pom.xml中包含了tomcat依赖项。

我正在运行的课程是这个 - >

AlpsWsApplication.java

@SpringBootApplication
public class AlpsWsApplication {
    private static final Logger logger = LoggerFactory
            .getLogger(AlpsWsApplication.class);
    public static void main(String[] args) {
        SpringApplication.run(AlpsWsApplication.class, args);
    }
}

这有hibernate,Apache qpid配置文件。

堆栈追踪:

ERROR 10 Mar 2016 14:01:10,185 [main] org.springframework.boot.SpringApplication: Application startup failed
com.ecwid.consul.transport.TransportException: java.net.ConnectException: Connection refused
    at com.ecwid.consul.transport.DefaultHttpTransport.executeRequest(DefaultHttpTransport.java:87)
    at com.ecwid.consul.transport.DefaultHttpTransport.makeGetRequest(DefaultHttpTransport.java:46)
    at com.ecwid.consul.v1.ConsulRawClient.makeGetRequest(ConsulRawClient.java:66)
    at com.ecwid.consul.v1.kv.KeyValueConsulClient.getKVValues(KeyValueConsulClient.java:135)
    at com.ecwid.consul.v1.kv.KeyValueConsulClient.getKVValues(KeyValueConsulClient.java:128)
    at com.ecwid.consul.v1.ConsulClient.getKVValues(ConsulClient.java:346)
    at org.springframework.cloud.consul.config.ConsulPropertySource.init(ConsulPropertySource.java:57)
    at org.springframework.cloud.consul.config.ConsulPropertySourceLocator.locate(ConsulPropertySourceLocator.java:70)
    at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:88)
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:628)
    at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:328)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101)
    at com.alps.AlpsWsApplication.main(AlpsWsApplication.java:13)
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)
    at com.ecwid.consul.transport.DefaultHttpTransport.executeRequest(DefaultHttpTransport.java:71)
    ... 14 more

2 个答案:

答案 0 :(得分:0)

'拒绝连接'只有一个含义:目标主机已启动,并且在指定端口没有任何内容侦听。所以要么你没有启动服务,要么你的IP地址或端口错误。

特别违背此处的评论:

  • 这不是'主机故障'条件
  • 这不是防火墙问题
  • 这不是网络连接问题(ping)。

答案 1 :(得分:0)

问题是我在pom.xml文件中包含了spring cloud consul依赖项,但没有启动服务器。