Spring 执行器邮件 HealthIndicators 不工作
我已经在 Spring Boot 中启用了 Spring 执行器并使用了以下配置,
management.health.mail.enabled=true
management.endpoint.health.show-details=always
[email protected],
spring.mail.port=587
但是每当我启动应用程序时,邮件服务器都不会被检查。在路径 /actuator/health
中:
{
"status": "UP",
"components": {
"db": {
"status": "UP" ...
},
"diskSpace": {
"status": "UP", ...
},
"hazelcast": {
"status": "UP",
},
"ping": {
"status": "UP"
}
}
}
I have enabled Spring actuator in Spring Boot and used following configuration
management.health.mail.enabled=true
management.endpoint.health.show-details=always
[email protected],
spring.mail.port=587
But whenever I start application, Mail server is not getting checked. in path /actuator/health
:
{
"status": "UP",
"components": {
"db": {
"status": "UP" ...
},
"diskSpace": {
"status": "UP", ...
},
"hazelcast": {
"status": "UP",
},
"ping": {
"status": "UP"
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它肯定会根据您的 Spring Boot 版本和其他依赖项而有所不同,但分析此问题的一种方法是测试。
Spring Boot MailHealthContributorAutoConfiguration 需要几个条件,其中之一是有效的 JavaMailSender 配置。
您尚未提供工作配置,但您可以使用类似的测试类测试您的设置,
请注意
@AutoConfigureMetrics
注释。配置
application-test.yml
看起来像:和邮件配置部分(使用您的邮件服务器或一些类似 GreenMail):
看看 满的项目。
It can surely vary depending on your Spring Boot Version and other dependencies, but one way to analyze this is a test.
Spring Boot MailHealthContributorAutoConfiguration expects couple of conditions, one of them being a valid JavaMailSender Config.
You have not provided a working configuration, but you can test your setup using a similar test class
Note the
@AutoConfigureMetrics
annotation.The config
application-test.yml
looks like:and the mail config part (with your Mail Server or some Mock like GreenMail):
Have a look at the full project.