【问题标题】:What is the exact purpose for spring.jmx.enabled?spring.jmx.enabled 的确切目的是什么?
【发布时间】:2021-01-28 19:22:22
【问题描述】:

对于 Spring Boot (v2.4.2),在Monitoring and Management over JMX 部分指出:

Java Management Extensions (JMX) provide a standard mechanism to monitor and manage applications. 
By default, this feature is not enabled and can be turned on by setting the configuration property 
spring.jmx.enabled to true. Spring Boot exposes management endpoints as JMX MBeans under
the org.springframework.boot domain by default.

因此spring.jmx.enabled默认为false

我不理解这种行为,因为对于基于 web 的快速 SB 应用程序,带有开发工具和执行器,甚至在声明 spring.jmx.enabled 时带有 falseDev Tools 和 @ 987654334@的依赖我总能看到org.springframework.boot域如下:

  • spring.jmx.enabled=falsedev toolsActuator

  • spring.jmx.enabled=false 和不带 dev tools 和带 Actuator

  • spring.jmx.enabled=true 且不带 dev tools 且不带 Actuator

  • spring.jmx.enabled=false 和没有 dev tools 和没有 Actuator

观察:我在使用和不使用 Dev Tools 和 Actuator 的情况下进行了测试,因为我认为它们中的任何一个都在内部将 spring.jmx.enabled 覆盖为 true,但事实并非如此正如我为最新的场景所确认的那样

那么当spring.jmx.enabledfalsetrue 时,应该观察到的显式区别是什么?在上面共享的场景中,总是出现org.springframework.boot 域,我可以访问管理方法上面显示的所有场景。我认为带有 false 的 spring.jmx.enabled 应该从一开始就暴露 org.springframework.boot 域。

【问题讨论】:

  • 你是如何启动应用程序的? SpringApplication 管理 bean 的存在告诉我,它是使用通常由工具使用的 spring.application.admin.enabled=true 启动的。
  • 我正在使用Boot Dashboard 视图通过 STS 执行应用程序。我没有在任何地方明确配置spring.application.admin.enabled 属性
  • 这方面的文档令人震惊。

标签: spring-boot jmx spring-boot-actuator spring-jmx


【解决方案1】:

当您在 STS 中启动应用程序时,它会将 spring.application.admin.enabled 属性设置为 true。这将启用 org.springframework.boot 域中的 MBean,STS 使用该域来管理应用程序并使用从通过 JMX 公开的 Actuator 端点检索到的信息来提供对其功能的洞察。

【讨论】:

  • 因此,如果我以独立模式 (java -jar abc.jar) 执行应用程序并且没有 IDE 涉及参考文档中提供的解释,那么为了获得完整的图片以及造成这种混乱的原因适用于那种情况,对吧?
猜你喜欢
  • 2015-11-13
  • 2016-11-24
  • 2013-08-13
  • 1970-01-01
  • 1970-01-01
  • 2011-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多