开发框架 springBoot

本文详细介绍Spring Boot中多环境配置文件的使用方法,以及如何通过Actuator进行应用的运行状态监控。包括配置文件的加载顺序、指定环境的运行方式,和Actuator依赖的引入与配置,以及健康检查等信息的获取。

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

1.多个环境的配置文件

在application.yml 中配置需要调用的配置文件

spring:
  profiles:
    active: dev

运行方式的,先运行application.yml 再根据active指定的配置文件,进行覆盖。

linux中启动程序指定配置文件

java -jar springbootdemo.jar -- spring.profiles.active=dev

2.运行状态监控Actuator

pom中引入依赖

<!--运行状态监控-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

在application.yml文件中配置

management:
  endpoints:
    web:
      exposure:
        include: "*"
  server:
    port: 10111
    servlet:
      context-path: /
    ssl:
      enabled: false
  endpoint:
    health:
      show-details: always

访问方式:http://localhost:10111/actuator/health

访问结果:

{"status":"UP","details":{"db":{"status":"UP","details":{"database":"MySQL","hello":1}},"diskSpace":{"status":"UP","details":{"total":463330078720,"free":113779286016,"threshold":10485760}}}}

 

转载于:https://www.cnblogs.com/hcfan/p/10118013.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值