I have spring MVC web application. I have used spring boot actuator in it by adding dependancies as below.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
In my configuration file, I have imported classes as below.
@Configuration
@ComponentScan({"com.test.*"})
@Import({EndpointWebMvcAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class, EndpointAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class,PublicMetricsAutoConfiguration.class})
@EnableWebMvc
@PropertySource("classpath:appconfig.properties")
public class SpringWebConfig extends WebMvcConfigurerAdapter {
}
Now when I hit url "http://localhost:8080/health", I am getting response
{"status":"UP","diskSpace":{"status":"UP","total":493767094272,"free":417100754944,"threshold":10485760}}
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 ?
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