Given this entry in application.properties:
application.properties
server.port=0
which causes Spring Boot to chose a random available port, and testi
You could do this too:
@Autowired private org.springframework.core.env.Environment springEnv; ... springEnv.getProperty("server.port");