SpringBoot Admin 濡備綍闆嗘垚閫氱煡鏈嶅姟
SpringBoot Admin鍙互閫氳繃闆嗘垚閭欢銆丼lack銆丠ipChat銆丮icrosoft Teams绛夐€氱煡鏈嶅姟鏉ュ疄鐜伴€氱煡鍔熻兘銆備笅闈互闆嗘垚閭欢閫氱煡涓轰緥杩涜璇存槑锛?/p>
- 娣诲姞渚濊禆锛氬湪pom.xml鏂囦欢涓坊鍔燬pring Boot Admin Server鐨勪緷璧栧拰Spring Boot Starter Mail鐨勪緷璧栥€?/li>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
- 閰嶇疆閭欢閫氱煡锛氬湪application.properties鏂囦欢涓厤缃偖浠堕€氱煡鐨勭浉鍏充俊鎭紝濡係MTP鏈嶅姟鍣ㄣ€佸彂浠朵汉閭銆佹敹浠朵汉閭绛夈€?/li>
spring.mail.host=smtp.example.com
spring.mail.port=587
spring.mail.username=your-email@example.com
spring.mail.password=your-email-password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.boot.admin.notify.mail.to=admin@example.com
spring.boot.admin.notify.mail.from=your-email@example.com
- 鍚敤閭欢閫氱煡锛氬湪Spring Boot Admin Server鐨勯厤缃被涓坊鍔燖EnableAdminServer鍜孈EnableScheduling娉ㄨВ锛屽苟閰嶇疆@EnableAdminServer.notifyMail()銆?/li>
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
@Configuration
@EnableAdminServer
public class AdminServerConfig {
@Bean
public NotifyMailNotifier notifyMailNotifier(JavaMailSender mailSender, MailProperties mailProperties) {
return new NotifyMailNotifier(mailSender, mailProperties);
}
}
閫氳繃浠ヤ笂姝ラ锛屽氨鍙互瀹炵幇SpringBoot Admin闆嗘垚閭欢閫氱煡鏈嶅姟銆傚叾浠栭€氱煡鏈嶅姟鐨勯泦鎴愭柟娉曠被浼硷紝鍙渶鏍规嵁鍏蜂綋鏈嶅姟鐨勯厤缃姹傝繘琛岀浉搴旂殑閰嶇疆鍗冲彲銆?/p>
相关问答