Spring Boot Admin郵件警報(bào)整合過程解析
一、前言
在Spring Boot Admin Server 中撒送預(yù)警郵件通知是很簡(jiǎn)單的,只需要簡(jiǎn)單的幾個(gè)配置就可以了。
二、代碼演示
1、microservice-monitor-server-> pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>microservice-minitor</artifactId> <groupId>com.microservice</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>microservice-monitor-server</artifactId> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-server</artifactId> <version>2.2.0</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
其中改動(dòng)的只是添加了spring-boot-starter-mail 的依賴
2、microservice-monitor-server-> application.yml
server: port: 8888 spring: application: name: SpringBootAdmin boot: admin: ui: title: SpringBootAdmin-Server notify: mail: from: 123@qq.com to: 345@outlook.com security: user: name: "admin" password: "admin" mail: host: smtp.qq.com username: 123@qq.com password: qq #授權(quán)碼 properties: mail: smtp: auth: true starttls: enable: true required: true eureka: instance: hostname: localhost metadata-map: user.name: ${spring.security.user.name} user.password: ${spring.security.user.password} client: register-with-eureka: true fetch-registry: true serviceUrl: defaultZone: http://localhost:8001/register/eureka/
只需要兩步就配置完成,根本就沒有編寫任何的Java的代碼,只需簡(jiǎn)單的配置就可以了。
三、運(yùn)行測(cè)試
能夠正常的發(fā)送接收郵件!
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- SpringBoot整合JavaMail通過阿里云企業(yè)郵箱發(fā)送郵件的實(shí)現(xiàn)
- Spring發(fā)送郵件如何內(nèi)嵌圖片增加附件
- SpringBoot基礎(chǔ)教程之集成郵件服務(wù)
- springboot實(shí)現(xiàn)發(fā)送郵件(QQ郵箱為例)
- Spring Boot如何開啟并使用郵件服務(wù)
- 基于SpringBoot實(shí)現(xiàn)定時(shí)發(fā)送郵件過程解析
- SpringBoot發(fā)送郵件功能 驗(yàn)證碼5分鐘過期
- Springboot實(shí)現(xiàn)郵件發(fā)送功能
- SpringBoot實(shí)現(xiàn)發(fā)送郵件功能
- 如何用Spring發(fā)送電子郵件
相關(guān)文章
關(guān)于對(duì)Java正則表達(dá)式"\\"的理解
正則表達(dá)式中,\代表轉(zhuǎn)義字符,通常是轉(zhuǎn)義一些特殊字符,下面這篇文章主要給大家介紹了關(guān)于對(duì)Java正則表達(dá)式"\\"的相關(guān)理解,需要的朋友可以參考下2022-09-09JAVA中讀取文件(二進(jìn)制,字符)內(nèi)容的幾種方法總結(jié)
本篇文章主要介紹了JAVA中讀取文件(二進(jìn)制,字符)內(nèi)容的方法總結(jié),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-02-02springboot項(xiàng)目如何引用公共模塊的bean
這篇文章主要介紹了springboot項(xiàng)目如何引用公共模塊的bean問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-08-08Intellij Idea修改代碼方法參數(shù)自動(dòng)提示快捷鍵的操作
這篇文章主要介紹了Intellij Idea修改代碼方法參數(shù)自動(dòng)提示快捷鍵的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2021-01-01SpringBoot通過RedisTemplate執(zhí)行Lua腳本的方法步驟
這篇文章主要介紹了SpringBoot通過RedisTemplate執(zhí)行Lua腳本的方法步驟,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-02-02Spring SpringMVC,Spring整合MyBatis 事務(wù)配置的詳細(xì)流程
這篇文章給大家介紹SSM整合詳細(xì)流程步驟 Spring SpringMVC,Spring整合MyBatis 事務(wù)配置,本文通過實(shí)例圖文相結(jié)合給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2020-10-10Java搭建簡(jiǎn)單Netty開發(fā)環(huán)境入門教程
這篇文章主要介紹了Java搭建簡(jiǎn)單Netty開發(fā)環(huán)境入門教程,有詳細(xì)的代碼展示和maven依賴,能夠幫助你快速上手Netty開發(fā)框架,需要的朋友可以參考下2021-06-06Spring Boot Admin實(shí)現(xiàn)服務(wù)健康預(yù)警功能
這篇文章主要介紹了Spring Boot Admin實(shí)現(xiàn)服務(wù)健康預(yù)警功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-05-05java?LeetCode刷題稍有難度的貪心構(gòu)造算法
這篇文章主要為大家介紹了java?LeetCode刷題稍有難度的貪心構(gòu)造題解示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02