I have existing Spring MVC web application. Now I just want to use the health check feature present in spring-boot-starter-actuator.
I am new to spring boot, so not sure if I need to convert my complete project to spring boot project for health check to work. Can I just include the dependency and somehow enable only the required feature?
I figured it out myself. Instead of spring-boot-starter-actuator
I am including spring-boot-actuator
. And I don't need to initialize the application using @SpringBootApplication
. Instead now I just import the auto-config classes that are required. So the config class now looks like this
@Configuration
@ComponentScan(basePackages = { "org.example" })
@Import({MyApplicationContext.class, EndpointWebMvcAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class, EndpointAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class})
@PropertySource("classpath:app.properties")
@EnableWebMvc
public class MyWebApplicationContext {
...
}
EndpointWebMvcAutoConfiguration
depends on ManagementServerProperties
hence had to import it. This seems to be the bare minimum configuration for me. Let me know if there is any better alternative
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