登录
首页 >  文章 >  java教程

如何解决Spring Boot 2.x中禁用`management.security.enabled`属性无效的问题

来源:亿速云

时间:2024-03-28 18:48:07 441浏览 收藏

学习知识要善于思考,思考,再思考!今天golang学习网小编就给大家带来《如何解决Spring Boot 2.x中禁用`management.security.enabled`属性无效的问题》,以下内容主要包含等知识点,如果你正在学习或准备学习文章,就都不要错过本文啦~让我们一起来看看吧,能帮助到你就更好了!

management.security.enabled=false无效

一、在1.5.x版本中通过management.security.enabled=false来暴露所有端点

SpringBoot2.x中management.security.enabled=false无效怎么解决

具体配置类:

org.springframework.boot.actuate.autoconfigure.ManagementServerProperties$Security

二、切换SpringBoot版本为2.x 使用IDE的搜索功能

找到类ManagementServerProperties,发现Security内部类已经被删除

三、去官网查看2.0暴露端点的方式

方式1:

# 启用端点 env
management.endpoint.env.enabled=true
 
# 暴露端点 env 配置多个,隔开
management.endpoints.web.exposure.include=env

方式2:

方式1中的暴露方式需要一个一个去开启需要暴露的端点,方式2直接开启和暴露所有端点

management.endpoints.web.exposure.include=*

注意在使用Http访问端点时,需要加上默认/actuator 前缀

management.security.enabled 过时

在Spring boot 2.0中

management.security.enabled=true

management:
 security:
  enabled:true

可以采用

management.endpoints.web.exposure.include=

代替的全部放开请使用*,或把需要开放的接口端点使用“,”隔开,如:env,health。

yaml 的配置*请加上“"”(引号)如下

management:
  endpoints:
    web:
      exposure:
        include: "*"

理论要掌握,实操不能落!以上关于《如何解决Spring Boot 2.x中禁用`management.security.enabled`属性无效的问题》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!

声明:本文转载于:亿速云 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>