Harshil Harshil - 1 year ago 171
Java Question

How to register spring MVC application to spring boot admin

I have spring MVC web application. I have used spring boot actuator in it by adding dependancies as below.


In my configuration file, I have imported classes as below.

ManagementServerPropertiesAutoConfiguration.class, EndpointAutoConfiguration.class,
public class SpringWebConfig extends WebMvcConfigurerAdapter {

Now when I hit url "http://localhost:8080/health", I am getting response


So, this works perfect. Now my question is how to register this spring MVC web application to spring-boot-admin server.

Can anyone help me ?

Answer Source

If you don't want to use Spring Boots autoconfiguration (@EnableAutoConfiguration), have a look at the SpringBootAdminClientAutoConfiguration form the spring-boot-admin-starter-client library there are all components configured used for registering at the admin server.

Primarily the ApplicationRegistrator and some taskScheduler for issuing the frequent registration.

If you don't want to use the client-lib at all you could also register via a simple http post request to the admin-server's /api/applications endpoint.

$ curl -H"Content-Type: application/json" --data '{ "serviecUrl":"http://localhost:8080/", "healthUrl":"http://localhost:8080/health", "managementUrl":"http://localhost:8080/","name":"my-app"}' http://<adminserver-host>:<port>/api/applications
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download