spring-boot - 当我使用@ComponentScan时,Spring Boot执行器不显示

标签 spring-boot spring-boot-actuator

我的应用程序如下所示。在此配置中,我的应用程序可以运行(它是使用 @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/

相关文章:

java - 未在 spring boot 中注册的自定义转换器

java - 拒绝用户 'root' 访问 @'localhost' - Spring Boot 和 MySQL 连接

spring-boot - 如何禁用 configserver Health 页面检查默认标签 git

java - Spring Integration + Spring Boot Actuator 端点未显示

java - Spring OAuth2 java.util.LinkedHashMap 无法转换为 org.springframework.security.web.authentication.WebAuthenticationDetails

java - 莫基托。如何基于模拟对象作为参数返回 boolean 值?

java - 如何将List转换为Map并使Map成为对象属性的关键

spring - 将 spring boot 从 2.1.9 升级到 2.2.0 ,现在启动时出现异常

jhipster - 在 jhipster 生成的应用程序中禁用 spring boot 审核

spring-cloud-starter-config POST/env 不工作