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: xxxx@qq.com
    #授权码 不知道怎么搞可以百度
    password: oyxqsnvlomkbbfjb  
    properties:
      mail:
        smtp:
          auth: true
          starttls:
            enable: true
            required: true
  boot:
    admin:
      notify:
        mail:
           #从那里发
          from: xxx@qq.com
          #发到哪里
          to: xxx@qq.com
          #配置是否启用邮件通知 false是不起用
          enabled: true          
          
management:
     security:
        enabled: false

info:
   app:
       name: "@project.name@"  #从pom.xml中获取,pom.xml中需build中加入插件spring-boot-maven-plugin
       description: "@project.description@" 
       version: "@project.version@"
       spring-boot-version: "@project.parent.version@"
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 上 就能监控 服务信息  并发送邮件

没有更多推荐了,返回首页