首先需要创建三个项目(或者两个):EurekaServerAdmin、EurekaClientAdmin及EurekaServer(可不要)

这里讲SpringBootAdmin监控服务和使用spring-boot-starter-mail进行服务下线邮件通知

EurekaServer用于服务注册发现,创建项目详情:注册服务与发现项目链接

再创建EurekaServerAdmin、EurekaClientAdmin,在创建springcloud项目的时候分别搜索server、client选择spring-boot-admin-starter-server与spring-cloud-starter-netflix-eureka-client依赖

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>

EurekaServerAdmin的完整pom文件:

<?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"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.2.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.cloud.lyl</groupId><artifactId>EurekaServerAdmin</artifactId><version>0.0.1-SNAPSHOT</version><name>EurekaServerAdmin</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><spring-boot-admin.version>2.1.1</spring-boot-admin.version><spring-cloud.version>Finchley.RELEASE</spring-cloud.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><!-- 移除tomcat依赖关系并在下面添加jetty --><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId></exclusion></exclusions></dependency><!-- 添加jetty --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jetty</artifactId></dependency><!-- 发送邮件的依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId></dependency><!-- springcloud组件的监测依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><!-- SpringBootAdmin的Server依赖 --><dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-server</artifactId></dependency><!-- 客户端依赖,与EurekaServer原理相同,将自己注册到server里面来 --><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.jolokia</groupId><artifactId>jolokia-core</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency><dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-dependencies</artifactId><version>${spring-boot-admin.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

EurekaClientAdmin的完整pom文件:

<?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"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.2.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.cloud.lyl</groupId><artifactId>EurekaClientAdmin</artifactId><version>0.0.1-SNAPSHOT</version><name>EurekaClientAdmin</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version><spring-boot-admin.version>2.1.1</spring-boot-admin.version><spring-cloud.version>Finchley.RELEASE</spring-cloud.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</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-web</artifactId></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-webflux</artifactId></dependency><dependency><groupId>org.jolokia</groupId><artifactId>jolokia-core</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-test</artifactId><scope>test</scope></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

EurekaServerAdmin的启动类中添加注解并添加配置类SecuritySecureConfig.java:

EurekaServerAdminApplication.java

package com.cloud.lyl;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Configuration;import de.codecentric.boot.admin.server.config.EnableAdminServer;@SpringBootApplication
@Configuration
@EnableAutoConfiguration
@EnableAdminServer
@EnableEurekaClient
public class EurekaServerAdminApplication {public static void main(String[] args) {SpringApplication.run(EurekaServerAdminApplication.class, args);}}

SecuritySecureConfig.java

package com.cloud.lyl.config;import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;import de.codecentric.boot.admin.server.config.AdminServerProperties;@Configuration
public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {private final String adminContextPath;public SecuritySecureConfig(AdminServerProperties adminServerProperties) {this.adminContextPath = adminServerProperties.getContextPath();}@Overrideprotected void configure(HttpSecurity http) throws Exception {// @formatter:offSavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();successHandler.setTargetUrlParameter("redirectTo");http.authorizeRequests().antMatchers(adminContextPath + "/assets/**").permitAll().antMatchers(adminContextPath + "/login").permitAll().anyRequest().authenticated().and().formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and().logout().logoutUrl(adminContextPath + "/logout").and().httpBasic().and().csrf().disable();// @formatter:on}
}

修改EurekaServerAdmin的配置文件:

application.yml

server:port: 8766
spring:application:name: EurekaServerAdminsecurity:user:#登陆admin的用户名与密码name: "admin"password: "admin"
###################
# 邮件通知配置
##################mail:host: smtp.163.comusername: #邮件发送方的账户如abc@qq.compassword: #授权码,在各邮箱设置界面进行设置boot:admin:notify:mail:from: #邮件发送方账户abc@qq.comto: #接受邮件的账户def@qq.comenabled: trueeureka:instance:leaseRenewalIntervalInSeconds: 10health-check-url-path: /actuator/healthprefer-ip-address: truemetadata-map:user.name: ${spring.security.user.name}user.password: ${spring.security.user.password}client:registryFetchIntervalSeconds: 5serviceUrl:defaultZone: ${EUREKA_SERVICE_URL:http://localhost:8761}/eureka/management:endpoints:web:exposure:include: "*"endpoint:health:show-details: ALWAYS

EurekaClientAdmin启动类不需要进行修改,修改配置文件

application.yml

spring:application:name: EurekaClientAdminsecurity:user:name: "client"password: "client"management:endpoints:web:exposure:include: "*"
logging:file: /var/log/sample-boot-application.logpattern:file: clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${PID}){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx
eureka:instance:leaseRenewalIntervalInSeconds: 10health-check-url-path: /actuator/healthprefer-ip-address: truemetadata-map:user.name:  ${spring.security.user.name}user.password:  ${spring.security.user.password}client:registryFetchIntervalSeconds: 5service-url:defaultZone: http://localhost:8761/eureka/
server:port: 8764

配置文件中对Eureka的配置详情见:eureka服务

接下来依次启动EurekaServer、EurekaServerAdmin、EurekaClientAdmin三个服务

依次在浏览器中打开两个网址:

EurekaServer: http://localhost:8761

EurekaServerAdmin:  http://localhost:8766

进去后EurekaServer中可以看到成功将EurekaServerAdmin、EurekaClientAdmin注册到eurekaserver中

而在EurekaServerAdmin中需要进行登录操作

使用配置文件中的用户名密码:admin

可见两个服务都在上面了,点进去可以查看相关的运行状况

最后我们来看下之前配的邮件通知下线,我们先把EurekaClientAdmin服务下线

然后设定的邮箱里面就收到了一条邮件

这里一个对服务的监控和服务下线邮件通知的提醒就完成了,欢迎留言交流

SpringBootAdminServer使用邮件监控服务(服务下线邮件提醒)相关推荐

  1. linux 网络监控 邮件,一种基于Linux的邮件监控方法与流程

    本发明涉及计算机安全技术领域,具体地说是一种实用性强.基于Linux的邮件监控方法. 背景技术: 随着计算机的普及以及人们对个人信息安全的重视,如何保障计算机乃至个人信息的安全成为了一个至关重要的问题 ...

  2. 上网监控软件,视频监控软件,聊天监控软件,屏幕监控软件,邮件监控软件...

    网眼监控软件-上网监控,视频监控,聊天监控,屏幕监控,邮件监控,文件复制拷贝监控,插入U盘监控,网址过滤,端口封堵等等,即可监管,也可控制,让您对员工的一切电脑操作行为了如指掌. 软件名称:网眼监控软 ...

  3. 利用Windows自带服务架设免费邮件服务器

    在Windows Server 2003中带有完整的SMTP和POP3服务,并且能够支持有域和无域两种环境,非常便于中小型企业实施.今天,小编就以Windows Server 2003企业版为例带领大 ...

  4. 梭子鱼推出Microsoft Office 365 邮件威胁扫描服务

    梭子鱼推出Microsoft Office 365 邮件威胁扫描服务,这一全新的Office365邮件威胁扫描服务能识别隐藏的APT,帮助客户即时了解邮件的安全状态 随着越来越多的邮件高级威胁影响着大 ...

  5. 应用层之E-mail服务及javaMail邮件发送的知识总结

    关于Email服务你需要知道的知识点: 概述: 今天来介绍一下应用层的电子邮件服务,我们每天几乎都在用,电子邮件(email)服务也是一种基于C/S模式的服务,它采用的是一种"存储-转发&q ...

  6. 邮件服务器fixpost服务(1)

    发邮件所用的协议,SMTP协议,端口TCP25 收邮件所用的协议,pop3.imap协议 邮件客户端(MUA):foxmail.闪电邮.邮件大师.outlook 搭建邮件服务器所用到的软件(MTA邮件 ...

  7. 解决.NET Core中MailKit无法使用阿里云邮件推送服务的问题

    在博问中(.net core怎么实现邮件发送)知道了MailKit无法使用阿里云邮件推送服务发送邮件的问题,自已实测也遇到同样的问题,而用自己搭建的邮件服务器没这个问题. 于是,向阿里云提交了工单.. ...

  8. zhajinhua2012邮件等网络服务的广泛应用

    摘要:zhajinhua2012 2012年07月18日,zhajinhua2012邮件等网络服务的广泛应用,玩家只要在3月8日凌晨0点到3月15日晚上24点规定时间内产生的在线时长均能兑换闪钻,晚饭 ...

  9. 使用阿里云邮件推送服务架设自己邮件验证与推送体系

    提示:阅读本文需提前了解的相关知识 1.电子邮件协议(http://baike.baidu.com/view/2367542.htm) 2.阿里云邮件推送(https://www.aliyun.com ...

最新文章

  1. python class属性
  2. java——-反省机制(代码例子)-
  3. 云考古 | Azure 自建 RDS 让 iPad 跑 Office 97
  4. 大数据分析要学习什么_为什么要学习数据分析
  5. NYOJ题目 263 精挑细选
  6. 洛谷——P1155 双栈排序
  7. 栈应用—括号匹配问题
  8. Android主备域名切换实施方案(Ping工具Demo)
  9. 微信对账单 java_微信下载对账单
  10. 计算机网络进入特权模式在哪里,计算机四级考试网络工程师考点一
  11. Linux学习~树莓派gpio控制
  12. 怎么调出全局搜索_华为手机怎么设置全局搜索,怎么开启以及怎么关闭
  13. java中循环里使用throw new抛出异常问题
  14. 小程序开发:WeUI用npm导入
  15. 牛客网输入输出练习c++ 个人版题解
  16. 商家使用会员卡有什么好处?手机app即可办理实体会员卡!
  17. git 强行拉取覆盖本地
  18. CKEditor&ckfindtor
  19. 最新体感:超级街霸4
  20. 周报(关于项目开发模式的一点总结)

热门文章

  1. 分享是奉献的果实,推荐5款高效率的黑科技软件
  2. iPhone 8 支广告
  3. 利用OpenAI Gym建立一个简单的自动驾驶模拟器
  4. 移动端ESRI二次开发小结(esri,android)
  5. 【渝粤教育】国家开放大学2018年春季 7067-22T (1)康复护理学 参考试题
  6. C++ char二维数组使用总结
  7. 网络创业成功五要素.doc
  8. 【ZZULIOJ】1006: 求等差数列的和
  9. 云计算(cloudcomputing)是基于互联网的相关服务的增加、使用和交付模式
  10. 智能机器人——基于Html5和css3的聊天器界面设计与实现