SpringCloud微服务监控——admin(二):admin服务端加入邮件通知

释放双眼,带上耳机,听听看~!

在admin监控的时候,我们希望的是如果有某个服务挂了,那么就发一个邮件,告诉我这个服务挂掉了。
1):在pom文件中,加入包依赖:


1
2
3
4
5
6
1<dependency>
2    <groupId>org.springframework.boot</groupId>
3    <artifactId>spring-boot-starter-mail</artifactId>
4</dependency>
5
6

2):在application.properties中加入邮件信息的配置:


1
2
3
4
5
6
7
8
9
10
11
12
13
1spring.mail.host=smtp.qq.com
2spring.mail.username=844645164
3# 这个地方使用的不是邮箱的密码,而是授权码(如何获取QQ邮箱授权码,自行百度)
4spring.mail.password=xxxxxxxxxxx
5spring.mail.properties.mail.smtp.auth=true
6spring.mail.properties.mail.smtp.starttls.enable=true
7spring.mail.properties.mail.smtp.starttls.required=true
8# 收件邮箱
9spring.boot.admin.notify.mail.to=903832439@qq.com
10# 发件邮箱
11spring.boot.admin.notify.mail.from=844645164@qq.com
12
13

至此,admin服务端就在监控服务状态变化的手,就可以发邮件通知了。


这里,如果有服务的状态变成DOWN,那么邮箱844645164@qq.com就会发送一个邮件到903832439@qq.com邮箱,内容如下:
SpringCloud微服务监控——admin(二):admin服务端加入邮件通知

给TA打赏
共{{data.count}}人
人已打赏
安全网络

CDN安全市场到2022年价值76.3亿美元

2018-2-1 18:02:50

安全资讯

710亿元!马斯克成2020年全球薪酬最高CEO

2021-8-16 15:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索