Commit 358b1b0b by 赵天增

发送邮件

parent 94c05446
......@@ -32,6 +32,10 @@
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.0.2-SNAPSHOT</version>
......
//package com.medtap.monitor.admin;
//
//import de.codecentric.boot.admin.server.domain.entities.InstanceRepository;
//import de.codecentric.boot.admin.server.notify.CompositeNotifier;
//import de.codecentric.boot.admin.server.notify.MailNotifier;
//import de.codecentric.boot.admin.server.notify.Notifier;
//import de.codecentric.boot.admin.server.notify.RemindingNotifier;
//import de.codecentric.boot.admin.server.notify.filter.FilteringNotifier;
//import org.springframework.beans.factory.ObjectProvider;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//
//import java.time.Duration;
//import java.util.Collections;
//import java.util.List;
//
//@Configuration
//public class NotifierConfiguration {
// private final InstanceRepository repository;
// private final ObjectProvider<List<Notifier>> otherNotifiers;
//
//
// @Primary
// @Bean(initMethod = "start", destroyMethod = "stop")
// public RemindingNotifier remindingNotifier() {
// RemindingNotifier notifier = new RemindingNotifier(filteringNotifier(), repository);
// notifier.setReminderPeriod(Duration.ofSeconds(10));
// notifier.setCheckReminderInverval(Duration.ofSeconds(10));
// return notifier;
// }
//}
......@@ -19,6 +19,10 @@ management:
# 微服务列表,如果服务不存在会触发邮件提醒
spring:
mail:
host: smtp.medtap.cn
password: webmaster@123
username: webmaster@medtap.cn
security:
user:
name: "server-monitor"
......@@ -29,7 +33,7 @@ spring:
mail:
enabled: true
to: tianzeng.zhao@medtap.cn
from: tianzeng.zhao@medtap.cn
from: webmaster@medtap.cn
services:
GATEWAY-CORE,
ITEM-API,
......
......@@ -161,7 +161,7 @@ public class SpringBootAdminApplication {
@Bean(initMethod = "start", destroyMethod = "stop")
public RemindingNotifier remindingNotifier() { // <2>
RemindingNotifier notifier = new RemindingNotifier(filteringNotifier(), repository);
notifier.setReminderPeriod(Duration.ofMinutes(10));
notifier.setReminderPeriod(Duration.ofSeconds(10));
notifier.setCheckReminderInverval(Duration.ofSeconds(10));
return notifier;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment