Spring Cloud Config端口冲突

时间:2014-11-25 17:54:44

标签: java spring spring-cloud

我开始在这里玩春天的云代码:https://github.com/spring-cloud/spring-cloud-config

我尝试在同一台主机上运行服务器和客户端。但是我一直收到错误(下面),声称该地址已被使用。默认情况下,服务器应该在端口8888上运行,因此客户端和服务器不能在同一主机上运行吗?我基本上试图回答这个问题,但我在途中遇到了这个端口问题:Spring-Cloud configuration server ignores configuration properties file

java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:414)
        at sun.nio.ch.Net.bind(Net.java:406)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:343)
        at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:737)
        at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:471)
        at org.apache.coyote.http11.Http11NioProtocol.start(Http11NioProtocol.java:80)
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:986)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:237)
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEm
beddedServletContainer.java:194)
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.ja
va:155)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplic
ationContext.java:272)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.jav
a:132)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)

        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
        at sample.Application.main(Application.java:15)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:408)
        at java.lang.Thread.run(Thread.java:745)

3 个答案:

答案 0 :(得分:2)

对于任何基于sprint引导的应用程序,您可以将application.properties添加到类路径中并覆盖任何服务器参数。

server.port= 9000

示例启动应用程序https://github.com/kamoor/spring-boot-sample

中提供了各种其他参数

答案 1 :(得分:2)

Spring Spring的Spring Boot 1.8和M2也遇到了同样的问题。使用Spring Boot 1.2.0.RC2和Spring Cloud版本1.0.0.M3,端口问题似乎已经消失

答案 2 :(得分:1)

配置服务器和客户端可以在同一主机上运行,​​但不能在同一个端口上运行。这就是我每天跑步的方式。您的应用正在运行哪些端口?