Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between management.server.port and management.port properties?

To run Actuator on a separate port we write management.server.port: 9001 in the application.properties file. But there is a confusing line in Actuator Guide code:

@TestPropertySource(properties = {"management.port=0"})

And then ...

@Value("${local.management.port}")
private int mgt;

Here is the source class https://github.com/spring-guides/gs-actuator-service/blob/master/complete/src/test/java/hello/HelloWorldApplicationTests.java

What's the difference between management.server.port, management.port and local.management.port?

like image 233
Diamond Avatar asked Jul 15 '18 12:07

Diamond


1 Answers

The management.server.port is used to expose management/actuator endpoints to a different HTTP port other than the one used for running the application.

And the management.port=0 is used to provide random port for the actuator to run while integration testing.

Whereas local.management.port is used to inject the random port.

Reference Spring Boot Actuator: Production-ready features and Random Port for Actuator

like image 131
Sri9911 Avatar answered Oct 16 '22 05:10

Sri9911