问题
I started playing around with the spring cloud code here: https://github.com/spring-cloud/spring-cloud-config
and I tried to run the server and client on the same host. However I keep getting an error (below) which claims that the address is already in use. The server should run on port 8888 by default, so is it not possible for both the client and the server to run on the same host? I'm basically trying to answer this question, but I'm running into this port problem on the way: 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)
回答1:
I had the same issue with Spring Boot version 1.8 and M2 of Spring Cloud. With Spring Boot 1.2.0.RC2 and Spring Cloud version 1.0.0.M3 the port problem seems to be gone
回答2:
For any sprint boot based application you can add application.properties in to class path and override any server parameters.
server.port= 9000
various other parameters are given in sample boot application https://github.com/kamoor/spring-boot-sample
回答3:
The config server and client can run on the same host, but not with the same port. It's how I run every day. What ports are your apps running on?
来源:https://stackoverflow.com/questions/27133478/spring-cloud-config-port-conflict