我的应用程序如下所示。在此配置中,我的应用程序可以运行(它是使用 @ComponentScan 引导的)。
不幸的是,/actuator/health 不起作用。当我删除 @ComponentScan 时,执行器可以工作,但我的应用程序无法工作。
我需要配置什么才能使@ComponentScan和执行器工作?
@EnableAutoConfiguration
@SpringBootApplication
@ComponentScan(basePackageClasses = {DistributionApp.class})
public class Main extends SpringBootServletInitializer {
...
}
最佳答案
我发现了实际问题。
我上过一个类:
@Component
@ApplicationPath("/")
这遮盖了/actuator 端点。所以他们没有出现。 所以这个问题与@ComponentScan无关,但只有当我自己的类被激活时才出现。
关于spring-boot - 当我使用@ComponentScan时,Spring Boot执行器不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63992340/