Spring Boot Actuator与Admin监控实战

Spring Actuator 与 Spring boot Admin 一.Springboot监控中心概述 1.什么是Springboot监控中心 针对于微服务的服务状态、Http请求资源监控 简述:针对微服务服务器监控,服务器内存变化(堆内存变化、线程变化、日志管理等),检测服务配置连接地址是否可用(比如MySQL等的连接可能是懒加载形式的,加载的时候没有报错,当访问的时候才会报错,实现的原理采用模拟访问)、统计现在有多少bean(是Spring容器中的bean... 阅读详情

Spring Boot Actuator 与 Spring Boot Admin 共同构成了一个强大的生产环境监控解决方案。其中,Actuator 为单个应用提供健康检查、指标收集等端点,而 Spring Boot Admin 则是一个管理 UI,能够集中展示和管理多个注册上来的客户端应用的状态 。以下将详细介绍如何使用 spring-boot-starter-actuator(客户端)和 spring-boot-admin-starter-server(服务端)构建一个多客户端监控系统,并提供具体代码。

1. 架构与依赖配置

架构说明:

  • 服务端 (Admin Server):一个独立的 Spring Boot 应用,作为监控中心,提供 Web UI 和 REST API,用于展示所有已注册客户端应用的详细健康状态、指标、日志等信息。
  • 客户端 (Client Applications):需要被监控的业务应用。它们通过 Actuator 暴露监控端点,并通过简单的配置自动向 Admin Server 注册。

依赖配置:

  • 服务端 pom.xml:
    核心是引入 spring-boot-admin-starter-server 依赖。

    <!-- 服务端:监控中心 -->
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-server</artifactId>
        <version>2.7.10</version> <!-- 请使用与Spring Boot版本兼容的版本 -->
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    
  • 客户端 pom.xml:
    需要引入 spring-boot-starter-actuator 以提供监控端点,并引入 spring-boot-admin-starter-client 以实现自动注册。

    <!-- 客户端:被监控的应用 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-client</artifactId>
        <version>2.7.10</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    

2. 服务端(Admin Server)实现

服务端的配置非常简单,主要是启用 Admin Server 功能。

2.1 主启动类 AdminServerApplication.java
使用 @EnableAdminServer 注解开启监控服务器功能。

package com.example.adminserver;

import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableAdminServer // 关键注解,启用 Spring Boot Admin Server
public class AdminServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(AdminServerApplication.class, args);
    }
}

2.2 服务端配置文件 application.yml
可以配置服务器端口、安全认证等。

server:
  port: 8080 # Admin Server 的访问端口

spring:
  application:
    name: admin-server

# 可选:配置安全认证(生产环境建议开启)
# spring.security.user.name=admin
# spring.security.user.password=admin

启动后,访问 http://localhost:8080 即可看到 Spring Boot Admin 的 Web 管理界面,初始时没有已注册的客户端。

3. 客户端(被监控应用)实现

客户端的核心是配置 Actuator 端点暴露和 Admin Server 的注册地址。

3.1 客户端配置文件 application.yml
以下配置是关键,它告诉客户端应用如何找到 Admin Server 并注册自己,同时暴露必要的 Actuator 端点 。

server:
  port: 8081 # 客户端A的端口,可启动多个实例,如8082, 8083
spring:
  application:
    name: order-service # 客户端应用名称,将在Admin UI中显示
  boot:
    admin:
      client:
        url: http://localhost:8080 # Admin Server 的地址
        instance:
          service-host-type: IP # 可选,注册时使用IP而非主机名

management:
  endpoints:
    web:
      exposure:
        include: '*' # 暴露所有端点给Admin Server,生产环境可按需选择,如 health,info,metrics,env
  endpoint:
    health:
      show-details: always # 总是显示详细的健康信息 

配置说明:

  • spring.boot.admin.client.url:指向 Admin Server 的地址。
  • management.endpoints.web.exposure.include:控制哪些 Actuator 端点可以被外部访问(这里 Admin Server 需要访问这些端点来获取数据)。设置为 * 表示暴露所有端点,但生产环境建议只暴露必要的,如 health, metrics, info, env, loggers 等 。
  • management.endpoint.health.show-details:设置为 always 后,Admin Server 可以获取到如数据库连接状态、磁盘空间等组件的详细健康信息 。

3.2 客户端启动与注册
无需编写任何注册代码。只要依赖和配置正确,客户端应用在启动时,spring-boot-admin-starter-client 会自动向配置的 Admin Server 发起注册请求。

4. 运行与监控演示

  1. 启动服务端:运行 AdminServerApplication,访问 http://localhost:8080

 

  1. 启动客户端:运行第一个客户端应用(例如 order-service,端口8081)。稍等片刻(通常几秒钟),刷新 Admin Server 页面,可以看到 order-service 出现在应用列表中,状态为 UP。
  2. 启动更多客户端:修改 application.yml 中的 server.port 和 spring.application.name(例如改为 user-service,端口8082),启动第二个客户端实例。Admin Server 的 UI 将自动更新,列出两个应用。
  3. 查看详细监控信息:在 Admin UI 的应用列表页,点击任意一个应用名称(如 order-service),将进入该应用的详细监控面板。这里聚合了来自该客户端 Actuator 端点的所有信息,主要包括:
监控维度对应 Actuator 端点在 Admin UI 中的功能与展示
健康状态/actuator/health显示应用整体状态(UP/DOWN)及详情(如磁盘、数据库状态)。
运行指标/actuator/metrics查看 JVM 内存、线程、HTTP 请求计数、响应时间等丰富的指标。
环境配置/actuator/env查看所有的配置属性,包括系统环境变量、application.yml 配置等。
日志管理/actuator/loggers动态调整运行时日志级别(如将 com.example 包的日志从 INFO 改为 DEBUG)。
线程转储/actuator/threaddump查看当前所有线程的快照,用于诊断死锁或高CPU问题。
HTTP 跟踪/actuator/httptrace查看最近的 HTTP 请求-响应跟踪信息。

5. 核心应用场景案例:电商微服务集群监控

场景描述:一个典型的微服务电商系统,包含 订单服务(order-service)、商品服务(product-service)、用户服务(user-service) 和 支付服务(payment-service)。每个服务都是独立的 Spring Boot 应用。

实施步骤与价值:

  1. 统一监控入口:搭建一个 Spring Boot Admin Server 作为统一的监控门户。所有微服务(客户端)通过上述配置自动注册。
  2. 全局状态一览:运维团队只需登录 http://admin-server:8080,即可在一个仪表板上看到所有四个微服务的实时健康状态(绿色“UP”或红色“DOWN”)。这解决了传统方式需要逐个检查每个服务的痛点。
  3. 快速故障定位:假设 支付服务 状态变为 DOWN。点击进入其详情页,查看 /actuator/health 详细信息,可能显示 db 状态为 DOWN,原因是数据库连接失败。这极大缩短了故障定位时间。
  4. 性能指标分析:发现 订单服务 的 API 响应变慢。在 Admin UI 中进入该服务的 Metrics 部分,查看 http.server.requests 指标,可以分析不同端点的平均耗时、请求频率,找出性能瓶颈。
  5. 动态运维操作:为了排查 用户服务 的一个复杂业务逻辑问题,无需重启服务。直接在 Admin UI 的 Loggers 页面,找到对应的业务类,将其日志级别从 INFO 临时调整为 DEBUG,即可在日志中看到更详细的调试信息。

技术实现要点:

  • 自动注册与发现:客户端利用 spring-boot-admin-starter-client 实现了对 Admin Server 的自动注册和定期心跳,Admin Server 自动感知客户端的上下线。
  • 数据拉取与展示:Admin Server 后台会定期(或实时)调用每个已注册客户端的 Actuator 端点(如 /actuator/health, /actuator/metrics),将获取到的 JSON 数据解析并在 Web UI 中以友好的图表和表格形式展示出来 。
  • 安全考虑:在生产环境中,务必为 Admin Server 的 Web 界面和 Actuator 端点配置安全认证(如集成 Spring Security),防止未授权访问导致敏感信息(如环境变量、线程堆栈)泄露 。

通过结合 Spring Boot Actuator 提供的标准化监控端点 和 Spring Boot Admin 提供的集中式管理 UI,我们能够以极低的代码侵入性,构建出一个功能全面、易于使用的分布式系统监控中心,完美契合微服务架构下的运维需求。​​​​​​

SpringBoot--SpringBoot 度量指标监控与健康检查 Spring Boot 度量指标监控与健康检查     一 使用 Actuator 检查与监控     1 修改Pom文件,添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </depende 阅读详情

相关推荐

使用 Spring Boot Admin 管理和监控 Spring Boot 应用程序

Spring Boot 是一款开源框架,它让初学者能够快速地开发出基于 Spring 框架的应用程序。在过去的一年中,Spring Boot 在 GitHub 上持续活跃,在全球范围内取得了令人瞩目的数据,获得了大量关注。目前,Spring Boot 的版本号已经从 2.x 发展到了 2.5.x、2.6.x 和 2.7.x。

AI天才研究院 2292

SpringBoot——监控中心(Admin )

一、简介 Spring Boot Admin是一个开源社区项目,用于管理和监控SpringBoot应用程序。 应用程序作为Spring Boot Admin Client向为Spring Boot Admin Server注册(通过HTTP)或使用SpringCloud注册中心(例如Eureka,Consul,Zookeeper)发现。 UI是的AngularJs应用程序,展...

默存 6543

NXP ChessDE的安装和激活

如果客户申请的是试用版,那么一份为期 30 天的 License 将会发送申请人的账号或邮箱中,客户使用该文件进行安装即可。② 将“VENDOR snpslmd /path/to/snpslmd”中的“/path/to/snpslmd”替换成 snpslmd.exe 实际存放路径(位于 SCL 安装目录下的 win32\bin 文件夹中,默认安装的情况下就是“VENDOR snpslmd C:\Synopsys\SCL\<version>\win32\bin\snpslmd.exe”)。

weixin_47351160的博客 2043

springcloud 微服务管理之 admin 实战使用(九)

Springcloud admin 是基于spring-boot-starter-actuator 实现的,admin 是根据统计出来的数据来进行展示的,可以很好的监控整 个微服务系统中的实例运行情况信息,前提结合注册中心才能拿到数据。 1、actuator 负责统计数据,引入jar: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-s...

nandao158的博客 1014

9.Vue前端使用iframe集成帆软报表的单点登录

CPT普通报表的地址:【帆软的服务http】+【/webroot/decision/view/report?【帆软的服务http】+【/webroot/decision/view/form?// fineReportHttp:帆软部署的地址。//如果为ie浏览器则页面加载完成后立即执行。// fineLinkSrc:帆软报表的url。//其他浏览器则重新加载onload事件。// 拿到配置的帆软报表的地址参数。//判断是否为ie浏览器。// 帆软报表登录和打开。// 帆软报表登录和打开。

qq_27860623的博客 4647

Jlink除了调试还能干啥?用JFlash SPI给W25Q64烧录固件的5个实用技巧

本文深入探讨了Jlink的隐藏功能,特别是通过JFlash SPI高效烧录W25Q64的5个进阶技巧。从硬件连接优化到批量处理脚本,再到数据安全验证,这些技巧能显著提升烧录速度和稳定性,适用于量产环境。文章还提供了详细的参数配置和脚本示例,帮助工程师充分发挥Jlink的潜力。

weixin_29164843的博客 408

SpringCloud环境搭建---Springboot-Admin

springboot- AdminServer 搭建过程 修改pom.xml &lt;dependencies&gt; &lt;!--Spring admin--&gt; &lt;dependency&gt; &lt;groupId&gt;de.codecentric&lt;/groupId&gt; &lt...

方小白 1517

【Unity】 预制体Prefab使用说明

在 Unity 中,Prefab 是一个可以预先制作并重复使用的 GameObject 或组件集合,Prefab 中的 GameObject 可以有子对象和其他组件。

灵境引路人 2849

springboot-admin对springboot项目监控

简介 springboot-admin实在Spring Boot Actuator的基础上提供简洁的可视化WEB UI,是用来管理SpringBoot应用程序的一个简单的界面,功能如下: 显示 name/id 和版本号 显示在线状态 Logging日志级别管理 JMX beans管理 Threads会话和线程管理 Trace应用请求跟踪 应用运行参数信息,如: Java 系统属性 Java 环...

爱飘de小子 768

GPU 运维实战:H100/H800/B300 换卡与压测

(烧多久、看什么、什么算合格)。文末还给了一个能直接跑的验收判定脚本,三个真实场景的裁决输出都在。

老韩的Linux云计算架构师进阶之路 270

YOLOv8改进 | 主干篇 | 利用MobileNetV1替换Backbone(轻量化网络结构)

本文给大家带来的改进机制是MobileNetV1,其是专为移动和嵌入式视觉应用设计的轻量化网络结构。这些模型基于简化的架构,并利用深度可分离卷积构建轻量级深度神经网络,其引入了两个简单的全局超参数,用于在延迟和准确性之间进行有效的权衡。实验表明,MobileNets在资源和准确性的权衡方面表现出色,并在多种应用(如对象检测、细粒度分类、面部属性识别和大规模地理定位)中展现了其有效性,这个模型非常适合轻量化的读者来使用。适用检测目标:轻量化网络结构适合轻量化的读者。

Snu77的博客 3966

AReaL-tau2-airline-sft-30B工具调用功能详解:构建自动化航空服务流程

AReaL-tau2-airline-sft-30B是一款基于Qwen3Moe架构的航空领域专用大模型,专为构建自动化航空服务流程设计。该模型通过强大的工具调用功能,能够实现机票预订、航班查询、行李处理等多种航空服务的自动化处理,为航空业提供高效智能的解决方案。 ## 模型核心架构与配置 AReaL-tau2-airline-sft-30B采用了先进的Qwen3Moe架构,具备以下关键配置参数

gitblog_00732的博客 730

FPGA实现LVDS接口(1)--IBUFDS原语、OBUFDS原语和IOBUFDS原语的介绍及使用(仿真/源码)

通过本文您会学到:Xinlix的源语IBUFDS、OBUFDS和IOBUFDS是什么?

孤独的单刀 2万+

SpringBoot监控利器:Actuator与Admin-UI可视化实战

在当今的软件开发领域,Spring Boot 凭借其便捷性和高效性成为了开发微服务的首选框架。然而,在生产环境中,对 Spring Boot 应用程序的监控和管理至关重要。Spring Boot Actuator 为我们提供了生产级的功能,如健康检查、指标收集等,而 Spring Boot Admin-UI 则为这些监控数据提供了可视化界面,极大地提升了监控和管理的效率。本文将详细介绍如何使用 Spring Boot Actuator 和 Admin-UI 实现对 Spring Boot 应用的可视化监控。

梵心白莲的博客 1150

第六节 LLaVA模型数据处理源码解读(input_ids/labels/attention_mask/image,上篇)

本篇文章直接介绍llava模型数据加工部分,整体结构说明llava多模态模型输入数据格式,其中包含input_ids/labels/attention_mask与image格式,并给出对应代码位置与整个数据加工流程。最重要,通过debug给出数据解释与代码解读,也通过一个真实数据给出模型输入格式说明。当你阅读完此篇文章,绝对透彻理解llava数据加工过程与内容。显然,一篇博客是无法呈现整个数据细节,我将继续下篇博客呈现数据细节处理。result = input.ne(3) # torch.ne函数调用。

weixin_38252409的博客 3193

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

9. Spring Boot2.5 实战 – 应用程序性 能监控

欢迎收看 spring boat 实战开发系列课程,这节课也讲另外一个非常重要的主题叫应用程序的性能监控。在生产环境下,应用程序的性能监控是非常重要的,开发阶段可能还不严重,但是生态环境下的话有可能基于高并发,比如双 11 等带来的这些流量冲击问题,可能应用程序在生产环境下,会因为一些配置参数等网络问题,导致应用程序性能可能出现这个问题,比如在高并发等会导致大量的内存耗尽等问题,或者应用程序代码本身在前期开发设计阶段做得不够详细,会出现缓慢的内存泄漏,都需要去做应用程。

天空鸟的博客 920

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Spring Boot Admin实战:从零搭建微服务监控中心与生产环境部署指南

在微服务架构中,应用监控是保障系统稳定性的基石。其核心原理是通过暴露应用内部运行状态端点,实现对服务健康度、性能指标和日志的集中采集与可视化。这项技术的价值在于显著提升运维效率,使开发者能快速定位性能瓶颈和故障根因。典型的应用场景包括电商、金融等分布式系统,用于实时监控服务状态、动态调整日志级别和接收告警通知。本文聚焦于Spring Boot Admin这一轻量级监控聚合工具,它基于Spring Boot Actuator构建,提供了开箱即用的管理界面。通过整合【服务发现】机制与【日志级别】动态管理功能,S

weixin_33895475的博客 323

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SpringCloud微服务实战——搭建企业级开发框架(四十四):【微服务监控告警实现方式一】使用Actuator + Spring Boot Admin实现简单的微服务监控告警系统

业务系统正常运行的稳定性十分重要,作为SpringBoot的四大核心之一,Actuator让你时刻探知SpringBoot服务运行状态信息,是保障系统正常运行必不可少的组件。spring-boot-starter-actuator提供的是一系列HTTP或者JMX监控端点,通过监控端点我们可以获取到系统的运行统计信息,同时,我们可以自己选择开启需要的监控端点,也可以自定义扩展监控端点。...

全栈程序猿的专栏 2129

Spring Boot应用开发全面指南:从入门到企业级实战

在Java后端技术体系中,Spring框架长期占据核心地位,而Spring Boot以其自动配置、起步依赖和内嵌容器三大机制,大幅降低了企业级应用的门槛。无论是构建基于MyBatis的多商户商城系统,还是搭建微服务架构,Spring Boot都能提供开箱即用的工程化能力。同时,结合Actuator与Spring Boot Admin可轻松实现应用监控与运维管理,配合Spring AI还能快速接入DeepSeek等大模型,让业务系统具备智能能力。本文从环境准备到项目演进,系统梳理Spring Boot开发的关

weixin_33417488的博客 273

Spring Boot Actuator & Admin 实战

Spring Boot Actuator 是 Spring Boot 的一个子项目,为应用提供了生产级别的功能。它提供了一系列的端点(endpoints),允许我们通过HTTP或JMX来监控应用的健康状况、指标、日志等。/actuator/health: 应用健康状态,通常由HealthIndicator实现。/actuator/info: 应用信息,可以来自Maven项目信息、自定义信息等。/actuator/metrics: 应用指标,如内存使用、HTTP请求计数等。

qq_33807380的博客 1049

Spring Boot项目依赖选型与版本管理实战指南

在Java后端开发中,依赖管理是项目稳定性的基石。Spring Boot通过starter机制与BOM统一管理第三方库版本,极大简化了集成成本。理解其原理能帮助开发者规避版本冲突、启动失败等常见问题。在创建Web应用、数据持久化、监控运维等场景中,按业务需求精准选择依赖,而非盲目堆砌,是提升开发效率的关键。本文梳理了常用依赖清单、Maven依赖树排查技巧、Spring Boot 2.x与3.x的差异,并给出实际工程中的选型建议,为构建可维护的Spring Boot项目提供参考。

weixin_29597551的博客 229

Spring Boot面试题深度解析:自动配置、事务与监控实战

Spring Boot作为Java后端开发的核心框架,其面试考察重点已从配置项背诵转向框架原理与生产实践的结合。理解自动配置机制是掌握框架的第一道关口,通过条件注解按需装配Bean,配合ConditionEvaluationReport可快速定位配置失效问题。在工程落地中,Actuator监控提供健康检查、运行时指标与运维操作能力,结合Spring Boot Admin能实现多服务可视化治理;多数据源路由、事务代理失效排查等实战细节,则直接体现候选人的排障深度。从配置文件加载优先级到内嵌容器替换,再到MyB

weixin_29895109的博客 251

Spring Boot应用监控实战

概述 之前讲过Docker容器的可视化监控,即监控容器的运行情况,包括 CPU使用率、内存占用、网络状况以及磁盘空间等等一系列信息。同样利用SpringBoot作为微服务单元的实例化技术选型时,我们不可避免的要面对的一个问题就是如何实时监控应用的运行状况数据,比如:健康度、运行指标、日志信息、线程状况等等。本文就该问题做一点探索并记录试验过程。 >注: 本文首发于 My Pers...

weixin_32942557的博客 1014

Spring-boot-starter-actuator的可视化spring-boot-admin

然后新建一个springboot项目导入spring-boot-admin-starter-server,将其作为我们的监控服务器。总结:Spring-boot-starter-actuator 通过请求可以获取被监控服务器的配置(前提是对外开放信息)基于Spring-boot-starter-actuator的可视化工具:spring-boot-admin。在被监控的服务器中导入spring-boot-admin-starter-client。然后可以观察到我们的应用被监控服务器所监控。

weixin_53050118的博客 1106

SpringBoot 监控

SpringBoot 自带控制功能Actuator,可以帮助实现对程序内部运行情况监控,比如监控状态、Bean加载情况、配置属性、日志信息等。 使用步骤 导入坐标 访问http://localhost:8080/actuator 新建模块,选择web、Actuator两个依赖 访问后返回 {"_links":{"self":{"href":"http://localhost:8080/actuator","templated":false},"health":{"href":"http://local

lqbz的总结 3015

跨域调用简介、Actuator插件使用、SpringBoot Admin使用、SpringCloud简介(Eureka实现)

跨域调用处理 什么是跨域 客户端发起异步请求一个服务器,该服务器再异步请求另一服务器 解决 使用jsonp(使用访问回调函数,可以随机生成回调函数名,保证不被劫持,只能通过get请求方式传参) 使用cors协议(不能处理劫持-在跨域异步调用时劫持请求,包装再转发-可以使用VPN专线连接保证不被劫持) cross-origin resource sharing(跨域资源共享) 前后端分离 前端项...

赵大土的博客 683
上一篇: Python介绍与环境安装(Windows和macOS)
下一篇: 基于角色的访问控制(RBAC)实现资源权限管理
IT_WEH_coder
博客等级 码龄5年 2万+粉丝 111原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT_WEH_coder

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值