Spring boot spring-boot-starter-actuator监控插件中 端口访问404问题

本文详细介绍了在Spring Boot 2.0及以上版本中如何配置Actuator来管理应用监控端口。由于安全性增强,默认仅开放/health和/info端口,需手动配置才能访问其他端口如env和beans。文章提供了开启和关闭特定端口的配置示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.项目中使用的maven插件对依赖包进行管理,在pom文件中需要添加配置,用来加载配置

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

2.导致借口访问失败的原因

spring-boot 1.0 版本能够正常访问
spring-boot 2.0 版本当中,作为安全性考虑,将actuator 控件中的端口,只默认开放/health 和/info 两个端口,其他端口默认关闭。当你需要使用气短监控端口时,需要手动在application.properties 文件中添加配置。配置形式为 management.endpoints.web.exposure.include=xxx 开启xxx端口的访问 , 如果去掉所有的端口访问限制,则配置形式为

management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.include=env
management.endpoints.web.exposure.include=*

2.0以上版本中,除了提供了开启某个端口的访问配置之外,还提供了关闭某个端口到的访问配置形式为

management.endpoints.web.exposure.exclude=xxx,xxx
management.endpoints.web.exposure.exclude=env,beans

2.0中还有一个变动,所有的端口 默认访问形式都是 actuator/XXX 例如actuator/health。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值