【发布时间】:2015-10-23 16:02:48
【问题描述】:
我有一个 Spring Boot 控制台应用程序,我通过 JMX 访问执行器端点。问题是返回的文本不是很漂亮,也不是 JSON。它看起来像这样:
{context=application, parent=null, beans=[{bean=helloWorldApplication, scope=singleton, type=com.surpreso.spring_skeleton.HelloWorldApplication, resource=null, dependencies=[helloWorldService]}, {bean=helloWorldService, scope=singleton, type=com.surpreso.spring_skeleton.HelloWorldService, resource=file [C:/src-tmp/spring-skeleton/target/classes/com/surpreso/spring_skeleton/HelloWorldService.class], dependencies=[]}, {bean=com.surpreso.spring_skeleton.DefaultConfig, ...
将其转换为可读格式的最佳方法是什么?是否可以将 JMX 执行器配置为漂亮打印?是否可以将 JMX 执行器配置为使用 JSON?
有一个关于Pretty print JSON output of Spring Boot Actuator endpoints 的相关问题,但在这种情况下,我坚持使用 JMX,因为我没有 Web 应用程序。下一步我将尝试 CRaSH,但我很好奇是否可以将 JMX 执行器配置为更可用。
我使用的是 1.2.5 版的 Spring Boot。
更新:CRaSH 实现使用相同的格式,因此不是解决方案。
更新 2:我在 1.3.0 中看到 this commit 关于“在所有 EndpointMBean 中使用已配置的 ObjectMapper(如果可用)”,但我不知道要设置哪些属性以进行漂亮的打印。很近了……
更新 3:spring.jackson.serialization.indent_output=true 通过 CRaSH 接口没有任何影响。我现在在 1.3.0.M2。
【问题讨论】:
标签: spring-boot spring-boot-actuator