Reputation: 1
This happens when application is launched via run as spring boot through STS.
Spring boot: 1.4.0.M1
I have an IIS running on port 80 but however I have changed the sever.port through STS configuration properties to 8090. STS Screen shot
Why STS embedded tomcat is using the port 80 even after it is changed? Kind of puzzled.
2016-04-15 05:22:03,985 [main] ERROR o.s.boot.SpringApplication - Application startup failed org.springframework.boot.context.embedded.PortInUseException: Port 80 is already in use at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.checkThatConnectorsHaveStarted(TomcatEmbeddedServletContainer.java:187) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:170) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:293) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:768) at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:362) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1183) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1172) at com.jbhunt.web.FinanceClaimsApplication.main(FinanceClaimsApplication.java:71)
I do not find an option to change the port other than the above mentioned. Any help would be greatly appreciated.
Upvotes: 0
Views: 1924
Reputation: 4897
You can configure your test class that load a context with a random port (working-with-random-ports).
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
WebEnvironment can bo set with the constants: RANDOM_PORT, DEFINED_PORT, MOCK or NONE.
The webEnvironment attribute allows specific “web environments” to be configured for the test. You can start tests with a MOCK servlet environment or with a real HTTP server running on either a RANDOM_PORT or a DEFINED_PORT.
Upvotes: 1