springboot2.x adminUI监控

1.server端

pom.xml


    org.springframework.boot
    spring-boot-starter-parent
    2.1.1.RELEASE
     


	UTF-8
	UTF-8
	1.8
	2.1.1



	
		de.codecentric
		spring-boot-admin-server
		${admin.ui.version}
	
	
		de.codecentric
		spring-boot-admin-server-ui
		${admin.ui.version}
	
	
		org.springframework.boot
		spring-boot-starter-web
	
     
        org.springframework.boot
        spring-boot-starter-mail
    
	
		org.springframework.boot
		spring-boot-starter-test
		test
	

application.yml

server:
  port: 9999


#配置邮件,用于spring boot client项目挂掉后发邮件
spring:
  mail:
    host: smtp.exmail.qq.com
    username: xxx@xxx
    password: xxx
    default-encoding: UTF-8
    properties:
      mail:
        smtp:
          auth: true
          starttls:
            enable: true
            required: true
  boot:
    admin:
      notify:
        mail:
          from: xxx@xxx
          to: xxx@xxx
        

主启动类:

import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableAdminServer
public class ActuatorApplication {

	public static void main(String[] args) {
		SpringApplication.run(ActuatorApplication.class, args);
	}
}

client端:


		org.springframework.boot
		spring-boot-starter-parent
		2.1.1.RELEASE
		 
	

	
		UTF-8
		UTF-8
		1.8
		2.1.1
	

	
		
			org.springframework.boot
			spring-boot-starter-web
		

		
			org.springframework.boot
			spring-boot-starter-test
			test
		
		
			de.codecentric
			spring-boot-admin-starter-client
			${admin.ui.version}
		

	

application.properties

server.port=8001

spring.boot.admin.client.url=http://localhost:9999
spring.boot.admin.client.instance.service-url=http://localhost:8001
spring.boot.admin.client.instance.name=client

#关闭安全验证
management.endpoint.beans.enabled=false
management.endpoints.web.exposure.include=*

info.app.name=demo

主启动类:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
@EnableScheduling
public class ActuatorClientDemoApplication {

	@RequestMapping("/hello")
	public String sayHello(String name){
		return "hello "+name;
	}

	@Scheduled(cron="0 0 10,14,16 * * ?")
	public void task(){
		System.out.println("我执行了....");
	}

	public static void main(String[] args) {
		SpringApplication.run(ActuatorClientDemoApplication.class, args);
	}
}

访问:http://localhost:9999/#/applications

springboot2.x adminUI监控_第1张图片

你可能感兴趣的:(spring,springboot)