第一章 初识 spring

一、 spring骨架生成 -- spring initializr     

       url:   https://start.spring.io/    

     可以生成Maven、Gradle,可以自由选择依赖,自由输入或者通过 “switch to the full  version”选择,选择完成后,单击“generate Project ” 生成spring boot框架。在本次学习中采用了 maven project进行框架生成。

二、pom.xml 解读

1、自动生成的框架通过  将 spring-boot-starter-parent 作为parent自动引入了 spring-boot-dependencies,并进行了自动配置srping-boot-maven-plugin。

2、非自动生成的框架可以自行配置panrent。 

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.1.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

三  actuator  健康检查、审计、统计、监控。只有health、info通过http暴露了出来。

Endpoint IDDescription
auditevents显示应用暴露的审计事件 (比如认证进入、订单失败)
info显示应用的基本信息
health显示应用的健康状态
metrics显示应用多样的度量信息
loggers显示和修改配置的loggers
logfile返回log file中的内容(如果logging.file或者logging.path被设置)
httptrace显示HTTP足迹,最近100个HTTP request/repsponse
env显示当前的环境特性
flyway显示数据库迁移路径的详细信息
liquidbase显示Liquibase 数据库迁移的纤细信息
shutdown让你逐步关闭应用
mappings显示所有的@RequestMapping路径
scheduledtasks显示应用中的调度任务
threaddump执行一个线程dump
heapdump返回一个GZip压缩的JVM堆dump

 

2、打开/关闭 actuator 方法

   在application.properties 中配置  management.endpoint.shutdowm.enabled = true

3、暴露 actuator 

默认,actuator endpoint通过JMX被暴露,而通过HTTP暴露的只有healthinfo

以下是你可以通过应用的properties可以通过HTTP和JMX暴露的actuator endpoint。

  • 通过HTTP暴露Actuator endpoints。

    # Use "*" to expose all endpoints, or a comma-separated list to expose selected ones
    management.endpoints.web.exposure.include=health,info 
    management.endpoints.web.exposure.exclude=
    
  • 通过JMX暴露Actuator endpoints。

    # Use "*" to expose all endpoints, or a comma-separated list to expose selected ones
    management.endpoints.jmx.exposure.include=*
    management.endpoints.jmx.exposure.exclude=


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值