1. 程式人生 > >Spring cloud admin 配置傳送郵件功能

Spring cloud admin 配置傳送郵件功能

首先引入pox配置

	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-eureka</artifactId>
		</dependency>
		<dependency>
			<groupId>de.codecentric</groupId>
			<artifactId>spring-boot-admin-server</artifactId>
			<version>1.5.6</version>
		</dependency>
		<dependency>
			<groupId>de.codecentric</groupId>
			<artifactId>spring-boot-admin-server-ui</artifactId>
			<version>1.5.6</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-mail</artifactId>
		</dependency>
	</dependencies>

啟動類註解

@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@EnableAdminServer

yml

檔案配置



logging:
  config: classpath:logback.xml
  #path: d:/logs/
server:
  port: 8880
  session-timeout: 60

spring:
  application:
    name: admin-server
  mail:
  #埠
    host: smtp.qq.com
    username: [email protected]
#授權碼 不知道怎麼搞可以百度 password: oyxqsnvlomkbbfjb properties: mail: smtp: auth: true starttls: enable: true required: true boot: admin: notify: mail: #從那裡發 from: [email protected] #發到哪裡 to:
[email protected]
#配置是否啟用郵件通知 false是不起用 enabled: true management: security: enabled: false info: app: name: "@[email protected]" #從pom.xml中獲取,pom.xml中需build中加入外掛spring-boot-maven-plugin description: "@[email protected]" version: "@[email protected]" spring-boot-version: "@[email protected]" eureka: instance: prefer-ip-address: true # 每隔10s傳送一次心跳 # leaseRenewalIntervalInSeconds: 10 # 告知服務端10秒還未收到心跳的話,就將該服務移除列表 # leaseExpirationDurationInSeconds: 10 client: # 表示eureka client間隔多久去拉取服務註冊資訊,預設為30秒 registry-fetch-interval-seconds: 10 # eureka 註冊服務地址 serviceUrl: defaultZone: http://使用者名稱:密碼@ip:8761/eureka

這樣配置之後  註冊到eureka 上 就能監控 服務資訊  併發送郵件