This is not a web project, but I still add spring-boot-starter-actuator
in pom, and specify management.port=8081
, then in last of run method of CommandLineRunner
, have below code,
System.in.read();
when started this project, it will hold on. Then I will to access http://localhost:8081/configprops
, but show below message:
This webpage is not available
So how could access actuator endpoints in non-web application?
BTW why I want to do so, because when started my project it can't load yml data successfully and caused NPE. So I want to access /configprops
to check it.
My yml like this:
spring:
profiles.active: default
---
spring:
profiles: default
user:
foo:
aaa: [email protected]
---
spring:
profiles: test
user:
foo:
aaa: [email protected]
bbb: [email protected]
@ConfigurationProperties(prefix="user", locations="user.yml")
public class UserConfig {
private HashMap<String, String> foo;
}
In a non web application you can access the Actuator endpoints with JMX. Use JConsole or JVisualVM to read the MBeans. See the Spring Boot documentation for more details: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-jmx
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