Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how could access actuator endpoints in non-web application

Tags:

spring-boot

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;    
}
like image 225
zhuguowei Avatar asked Oct 19 '22 19:10

zhuguowei


1 Answers

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

like image 110
dunni Avatar answered Nov 25 '22 08:11

dunni