Spring Boot Admin的简单使用

Spring Boot Admin 是一个管理和监控Spring Boot 应用程序的可视化监控软件

1.而在springboot中使用起来也十分方便,首先我们先添加web依赖和Spring Boot Admin依赖

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>


		<dependency>
			<groupId>de.codecentric</groupId>
			<artifactId>spring-boot-admin-starter-server</artifactId>
			<version>2.0.2</version>
		</dependency>
	</dependencies>

然后我们再在项目的启动类上添加@EnableAdminServer注解

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import de.codecentric.boot.admin.server.config.EnableAdminServer;

@SpringBootApplication
@EnableAdminServer
public class SpringBootAdminApplication {

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

}

这样在项目启动的时候就自动启动了springbootadmin,接下来运行项目,然后在浏览器上输入http://localhost:8080/#/applications就可以看到这个页面

2.然后我们再创建另一个项目,并把它注册进我们的Spring Boot Admin 里面

首先我们先添加依赖

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>

		<dependency>
			<groupId>de.codecentric</groupId>
			<artifactId>spring-boot-admin-starter-client</artifactId>
			<version>2.0.2</version>
		</dependency>

然后再在我们的application.properties里面进行配置

management.endpoints.web.exposure.include=*
management.endpoints.web.cors.allowed-origins=*
management.endpoints.web.cors.allowed-methods==GET,POST
management.endpoint.health.show-details=always
info.author.name=A517
server.port=8081
spring.boot.admin.client.url=http://localhost:8080

首先我们的client项目的端口号要进行修改,然后通过配置

1.management.endpoints.web.exposure.include=*//暴露端口信息
2.management.endpoints.web.cors.allowed-origins=*//允许跨域
3.management.endpoints.web.cors.allowed-methods==GET,POST//允许方法
4.management.endpoint.health.show-details=always//通过权限配置,有never和when-authorized和always三种属性来进行查看权限

然后运行项目,就会看到项目的信息已被注册进去

不过如果在client项目配置了安全框架的话,在安全配置哪里把client的.antMatchers("/actuator/**").permitAll()给暴露就好了,

这就是springbootadmin的简单使用

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值