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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With