我编写了两个HealthIndicator,一个实现HealthIndicator Java接口的CustomHealthIndicator.java,以及一个ping HSM的自己的HSMHealthIndicator.java。当我编写代码时,我将此配置放在application.properties中:
management.security.enabled=true
endpoints.health.sensitive=false
endpoints.health.enabled=true
endpoints.health.time-to-live=15000
几天前,我的老板在application.yml配置文件中移动了这些键/值:
management:
security:
enabled: true
endpoints:
health:
sensitive: false
enabled: true
time-to-live: 15000
因为在我们的应用程序中,与.properties相反,.yml不应该被外部化(因为它不应该被用户编辑,所以它不会被Maven复制到" target"目录中在建设期间。)
问题是我注意到我的代码不再读取键/值了。实际上,当我连接到http://localhost:8080/health时,显示的唯一内容是:
{"status":"UP"}
而我曾经有过:
{"status":"UP","custom":{"status":"UP"},"diskSpace":{"status":"UP","total":107374178304,"free":25598341120,"threshold":10485760},"db":{"status":"UP","database":"PostgreSQL","hello":1}}
其他证据:当我连接到我的自定义端点(http://localhost:8080/HSMAndDbHealth)时,我现在已经:
The JWT is missing from the 'Authentication'header
而我曾经有过:
{"code":"UP","message":"Database and HSM are UP"}
为什么在将它们放入application.yml文件时,不会读取配置执行器的键/值?
答案 0 :(得分:1)
可能有一个或多个空格字符“已损坏”。复制并粘贴多个工作键/值,并按所需的键/值重新设置这些键/值。