我有一个 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?
有一个关于Spring Boot Actuator endpoints 的漂亮打印 JSON 输出的相关问题,但在这种情况下,我坚持使用 JMX,因为我没有 Web 应用程序。下一步我将尝试 CRaSH,但我很好奇是否可以将 JMX 执行器配置为更可用。
我正在使用 1.2.5 版的 Spring Boot。
更新: CRaSH 实现使用相同的格式,所以它不是一个解决方案。
更新 2:我在 1.3.0 中看到了这个关于“在所有 EndpointMBeans 中使用配置的 ObjectMapper,如果可用的话”的提交,但我不知道为漂亮的打印设置哪些属性。很近 ...
更新 3:spring.jackson.serialization.indent_output=true
通过 CRaSH 界面没有任何影响。我现在在 1.3.0.M2。