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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…