【问题标题】:Spring boot actuator not showing when I use @ComponentScan当我使用@ComponentScan 时没有显示弹簧启动执行器
【发布时间】:2020-09-21 12:32:54
【问题描述】:

我的应用程序如下所示。在此配置中,我的应用程序可以工作(它使用 @ComponentScan 引导)。

不幸的是 /actuator/health 不起作用。当我删除 @ComponentScan 时,执行器工作,但我的应用程序不工作。

我需要配置什么才能使@ComponentScan 和执行器都工作?

@EnableAutoConfiguration
@SpringBootApplication
@ComponentScan(basePackageClasses = {DistributionApp.class})
public class Main extends SpringBootServletInitializer {
...
}

【问题讨论】:

  • 对不起,我们需要先看项目结构和配置类。或者,在 Github 上分享这个项目会很棒。
  • 不幸的是,这是一个内部项目。所以我不能分享完整的代码。需要注意的一点是,业务逻辑与 Main 类位于一个单独的项目中。 (我认为这就是我们需要 ComponentScan 的原因)。

标签: spring-boot spring-boot-actuator


【解决方案1】:

我找到了实际问题。

我有一个课:

@Component
@ApplicationPath("/")

这会影响 /actuator 端点。所以他们没有出现。 所以这个问题与@ComponentScan 无关,只是在我自己的类被激活时才出现。

【讨论】:

    猜你喜欢
    • 2022-07-07
    • 2015-03-08
    • 1970-01-01
    • 1970-01-01
    • 2017-04-21
    • 1970-01-01
    • 2019-01-12
    • 2018-10-12
    • 2016-11-05
    相关资源
    最近更新 更多