Spring Boot Admin Server(Spring Boot Actuator)与Nacos整合配置

  1. 新建一个admin server工程
  2. 新建bootstrap.yml文件(内设置了spring security的密码,需在pom内加入security的pom配置):
server:
  port: #{port}
spring:
  application:
    name: admin-server
  cloud:
    nacos:
      discovery:
        server-addr: #{ip:port}
        namespace: #{namespace}
  boot:
    admin:
      ui:
        title: 应用服务状态监控
  security:
    user:
      name: #{name}
      password: #{pwd}
#开启全部
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS
  1. 启动类增加注解:
@EnableDiscoveryClient
@EnableAdminServer
  1. 其他待监控应用增加pom配置(版本号跟随实际spring boot版本号)
<!-- spring-boot-security -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
  1. 访问localhost:port即可,密码为bootstrap.yml内设置的spring security密码
  2. 如有整合了类似Oauth2.0这类授权服务,需配置Actuator的部分接口路径以跳过鉴权
    类似以下配置:
 @Override
    protected void configure(HttpSecurity http) throws Exception {
        //所有请求必须认证
        http.authorizeRequests()
                .antMatchers("/oauth/**","/webjars/**", "/doc.html", "/swagger-resources/**",
                        "/v2/api-docs/", "/actuator/**", "/instances/**").permitAll()
                .anyRequest().authenticated()
                .and().csrf().disable();
    }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值