《Spring Boot in Action》【7. Actuator】

Spring Cloud与Spring Boot版本匹配关系解析 微服务架构中,Spring Cloud作为Spring Boot的增强套件,其版本兼容性直接影响系统稳定性。版本匹配遵循严格的地基与上层结构关系,如2023年推荐的Spring Cloud 2022.0.x与Spring Boot 3.0.x组合。理解版本号语义化规则(主版本、次版本、修订号)及官方版本对照表是避免依赖冲突的关键。企业级项目中,通过Maven或Gradle的BOM(Bill of Materials)管理依赖版本,结合CI/CD管道中的版本校验脚本,可有效预防版本错配问题。本文以Spring 阅读详情

7. Actuator

启用Actuator,你只要在build.gradle中加入:

compile 'org.springframework.boot:spring-boot-starter-actuator'

Spring Boot Actuator提供了一系列RESTful接口:

HTTP方法路径描述
GET/beansSpring应用上下文中所有bean以及它们之间的依赖关系
GET/autoconfig自动配置报告,哪些自动配置生效或无效
GET/env各种环境属性
GET/env/{name}根据名字检索环境属性
GET/configprops各种配置属性
GET/mappingsURI路径到控制器的映射
GET/metrics各种指标
GET/metrics/{name}根据名字检索指标
GET/trace最近100条HTTP请求追踪(数据在内存里)
GET/dump线程活动的快照
GET/health应用健康指标,由HealthIndicator接口的实现提供
POST/shutdown关闭应用
GET/info提供关于应用的自定义信息

这些信息主要分为三类:配置(configuration)、指标(metrics)、其他(miscellaneous)。为了安全,任何名字或者名字最后部分是“password”、“secret”或者“key”的属性,都会被打星显示。

7.1 配置信息

包括/beans、/autoconfig、/env、/env/{name}、/configprops、/mappings

7.2 指标信息

/metrics接口返回各种指标,按照前缀分类:

分类前缀描述
垃圾收集器gc.*mark-sweep和scavenge垃圾收集器的垃圾收集计数和持续时间 (from java.lang.management.GarbageCollectorMXBean)
内存mem.*分配给应用的内存和空闲的内存 (from java.lang.Runtime)
堆heap.*当前内存使用 (from java.lang .management.MemoryUsage)
类加载器classes.*JVM类加载器加载和未加载的类数量 (from java.lang.management.ClassLoadingMXBean)
系统processors,uptime,instance.uptime,systemload.average处理器数量 (from java.lang.Runtime),运行时间 (from java.lang.management.RuntimeMXBean),平均系统负载 (from java.lang.management.OperatingSystemMXBean)
线程池threads.*线程、守护线程的数量,以及JVM启动以来的线程峰值 (from java.lang.management.ThreadMXBean)
数据源datasource.*数据源连接数量 (from the data source’s metadata,仅当存在datasource bean时才有)
HTTP会话httpsessions.*活跃的和最大的会话数量 (from the embedded Tomcat bean,仅当有内置服务器时才有)
HTTPcounter.status.,gauge.response.HTTP请求的各种度量和统计

/health接口返回各种健康指标:

Health indicatorKeyReports
ApplicationHealthIndicatornoneAlways “UP”
DataSourceHealthIndicatordb“UP” and database type if the database can be contacted; “DOWN” status otherwise
DiskSpaceHealthIndicatordiskSpace“UP” and available disk space, and “UP” if available space is above a threshold; “DOWN” if there isn’t enough disk space
JmsHealthIndicatorjms“UP” and JMS provider name if the message broker can be contacted; “DOWN” otherwise
MailHealthIndicatormail“UP” and the mail server host and port if the mail server can be contacted; “DOWN” otherwise
MongoHealthIndicatormongo“UP” and the MongoDB server version; “DOWN” otherwise
RabbitHealthIndicatorrabbit“UP” and the RabbitMQ broker version; “DOWN” otherwise
RedisHealthIndicatorredis“UP” and the Redis server version; “DOWN” otherwise
SolrHealthIndicatorsolr“UP” if the Solr server can be contacted; “DOWN” otherwise

假设你需要关闭你的应用,比如在微服务架构中,你需要优雅地关闭其中一个应用实例,你可以这样:

curl -X POST http://localhost:8080/shutdown

显然,关闭应用是危险的行为,因此/shutdown默认是不启用的,你需要设置endpoints.shutdown.enabled为true才能开启,同时你应该注意/shutdown接口的权限。

/info接口返回应用的信息,默认返回空的JSON对象({}),你通过配置info打头的属性来添加更多返回:

info:
  contact:
    email: support@myreadinglist.com
    phone: 1-888-555-1971

7.3 Remote Shell

Spring Boot集成了CRaSH(可内置在Java应用中的shell),并提供了一系列命令,首先加入依赖:

compile("org.springframework.boot:spring-boot-starter-remote-shell")

然后待应用起来之后,你可以使用SSH连上去(端口2000),密码就是log里打印出来的那串随机密码:

ssh user@localhost -p 2000

可以使用由Spring Boot提供的命令:autoconfig、beans、metrics(可以看到动态更新,Ctrl-C退出),但是并不是每个Web接口都有对应的命令,这时候你需要endpoint命令:

endpoint list

这会返回endpoint列表,不过不是url,而是它们的bean name:

requestMappingEndpoint
environmentEndpoint
healthEndpoint
beansEndpoint
infoEndpoint
metricsEndpoint
traceEndpoint
dumpEndpoint
autoConfigurationReportEndpoint
configurationPropertiesReportEndpoint

然后使用endpoint invoke命令(去掉“Endpoint”后缀):

endpoint invoke health

7.4 自定义

7.4.1 修改endpoint IDs

每个Actuator endpoint都有一个ID来决定路径,比如/beans的默认ID就是beans,通过修改endpoints.endpoint-id.id属性就能修改路径,比如修改/shutdown为/kill:

endpoints:
  shutdown:
    id: kill

7.4.2 禁用(启用)endpoints

你还可以禁用某些endpoint:

endpoints:
  metrics:
    enabled: false

你可以禁用所有,并启用某些:

endpoints:
  enabled: false
  metrics:
    enabled: true

7.4.3 添加自定义metrics和gauges

比如我们需要记录用户保存了几次书到reading list,以及最后一次保存的时间,并通过/metrics暴露出来,Actuator为我们自动配置了一个CounterService实例,帮助完成计数功能:

package org.springframework.boot.actuate.metrics;

public interface CounterService {
  void increment(String metricName);
  void decrement(String metricName);
  void reset(String metricName);
}

还有一个GaugeService实例,帮助给一个指标设置一个值:

package org.springframework.boot.actuate.metrics;

public interface GaugeService {
  void submit(String metricName, double value);
}

你只需要注入这两个bean,然后直接调用方法即可:

@RequestMapping(method = RequestMethod.POST)
public String addToReadingList(Reader reader, Book book) {

  book.setReader(reader);
  readingListRepository.save(book);

  counterService.increment("books.saved");
  gaugeService.submit("books.last.saved", System.currentTimeMillis());

  return "redirect:/";
}

对于稍微复杂点的metrics,上面那两个Service估计不够用了,这时候你可以实现PublicMetrics接口:

package org.springframework.boot.actuate.endpoint;

public interface PublicMetrics {
  Collection<Metric<?>> metrics();
}

比如,我们要知道application context启动的时间,bean的数量,bean定义的数量以及注解为@Controller的bean的数量:

package readinglist;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.PublicMetrics;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

@Component
public class ApplicationContextMetrics implements PublicMetrics {

  @Autowired
  private ApplicationContext context;

  @Override
  public Collection<Metric<?>> metrics() {
    List<Metric<?>> metrics = new ArrayList<Metric<?>>();
    metrics.add(new Metric<Long>("spring.context.startup-date", context.getStartupDate()));
    metrics.add(new Metric<Integer>("spring.beans.definitions", context.getBeanDefinitionCount()));
    metrics.add(new Metric<Integer>("spring.beans", context.getBeanNamesForType(Object.class).length));
    metrics.add(new Metric<Integer>("spring.controllers", context.getBeanNamesForAnnotation(Controller.class).length));
    return metrics;
  }
}

然后访问/metrics,就会显示我们自定义的指标:

{
  ...
  spring.context.startup-date: 1429398980443,
  spring.beans.definitions: 261,
  spring.beans: 272,
  spring.controllers: 2,
  books.count: 1,
  gauge.books.save.time: 1429399793260,
  ...
}

spring.controllers为2,是因为统计了ReadingListController和Spring Boot提供的BasicErrorController。

7.4.4 添加自定义trace repository

/trace接口默认使用容量为100的内存repository,我们可以自己声明InMemoryTraceRepository bean,比如设置容量为1000:

package readinglist;

import org.springframework.boot.actuate.trace.InMemoryTraceRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ActuatorConfig {

  @Bean
  public InMemoryTraceRepository traceRepository() {
    InMemoryTraceRepository traceRepo = new InMemoryTraceRepository();
    traceRepo.setCapacity(1000);
    return traceRepo;
  }

}

虽然容量是增加了,但还是消耗内存,而且没有持久化,所以我们可以自己实现Spring Boot的TraceRepository接口:

package org.springframework.boot.actuate.trace;

import java.util.List;
import java.util.Map;

public interface TraceRepository {
  List<Trace> findAll();
  void add(Map<String, Object> traceInfo);
}

比如实现存到MongoDB:

package readinglist;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.trace.Trace;
import org.springframework.boot.actuate.trace.TraceRepository;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.stereotype.Service;

@Service
public class MongoTraceRepository implements TraceRepository {

  @Autowired
  private MongoOperations mongoOps;

  @Override
  public List<Trace> findAll() {
    return mongoOps.findAll(Trace.class);
  }

  @Override
  public void add(Map<String, Object> traceInfo) {
    mongoOps.save(new Trace(new Date(), traceInfo));
  }
}

你只要加入MongoDB的starter,就会自动配置好MongoOperations bean:

compile("org.springframework.boot:spring-boot-starter-data-mongodb")

7.4.5 自定义健康指标

比如我们要添加一个检测Amazon能否访问的健康指标:

package readinglist;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class AmazonHealth implements HealthIndicator {

  @Override
  public Health health() {
    try {
      RestTemplate rest = new RestTemplate();
      rest.getForObject("http://www.amazon.com", String.class);
      return Health.up().build();
    } catch (Exception e) {
      return Health.down().build();
    }
  }
}

如果需要更详细的信息,可以调用withDetail()方法,比如把catch中的代码改成:

return Health.down().withDetail("reason", e.getMessage()).build();

7.5 Actuator接口安全

给Actuator路径加权限和一般的路径加权限是一样的,但是要用antMatchers把所有接口列一遍显然比较麻烦,所以可以配置一个公共的前缀:

management:
  context-path: /mgmt

然后就在SecurityConfig.java中的configure()方法中加入:

.antMatchers("/mgmt/**").access("hasRole('ADMIN')")
Spring Boot Admin安全认证实战:构建生产级微服务监控中心 在微服务架构中,监控是保障系统稳定性的关键环节。Spring Boot Actuator作为标准监控端点,提供了应用内部运行状态的详细指标,但其分散性和安全性不足。通过引入Spring Boot Admin这一聚合监控平台,可以实现对多个微服务实例的集中可视化管理。其核心原理是基于客户端-服务器架构,自动收集并展示Actuator端点数据。该技术的核心价值在于提升运维效率与系统可观测性,广泛应用于微服务集群的健康检查、性能监控和日志管理。本文聚焦于通过集成Spring Security实现表单登录认证,解决 阅读详情

相关推荐

Spring Boot热部署实战:从DevTools到Jrebel的配置与原理详解

热部署与热加载是提升Java开发效率的核心技术,其本质是在应用运行时更新代码而无需重启。从原理上看,它们主要基于JVM的类加载机制,通过自定义类加载器或字节码增强技术实现类的动态替换。这项技术的核心价值在于极大缩短了“编码-验证”的反馈循环,将开发者从频繁重启的等待中解放出来,尤其适用于微服务架构下启动缓慢的大型项目。在Spring Boot开发中,热部署的典型应用场景包括快速迭代业务逻辑、调试API接口以及实时预览静态资源修改。本文聚焦于Spring Boot生态,深入解析了官方DevTools的快速重启

weixin_33850015的博客 408

官网spring boot配置大全(四)

---------------------------------------- INTEGRATION PROPERTIES ---------------------------------------- ACTIVEMQ (ActiveMQProperties) spring.activemq.broker-url= # URL of the ActiveMQ broker. Auto-ge...

Retank的博客 1995

GitHub开源Spring实战第6版全彩文档:现代Java开发核心指南

Spring框架作为Java企业级开发的核心技术栈,通过控制反转(IoC)和面向切面编程(AOP)等核心原理,实现了组件解耦和代码复用,极大提升了开发效率和系统可维护性。其技术价值在于提供了一套完整的、标准化的企业应用解决方案,广泛应用于微服务架构、云原生应用和大型分布式系统等场景。Spring Boot进一步简化了配置和部署流程,使得开发者能够快速构建生产级应用。本文聚焦于Spring实战第6版全彩开源文档,深入解析Spring Boot 3.0、Spring 6.0及Java 17+等最新技术栈的实战应

迷彩风情 378

spring-boot-starter-actuator配置详细

#ACTUATOR PROPERTIES #MANAGEMENT HTTP SERVER(ManagementServerProperties) management.server.add-application-context-header=false #在每个响应中添加“X-Application-Context”HTTP标头. management.server.address= #管理端点应绑定到的网络地址.需要自定义 management.server.port.management.serv.

hhj13978064496的博客 2829

Spring Boot in Action

A developer-focused guide to writing applications using Spring Boot. You'll learn how to bypass the tedious configuration steps so that you can concentrate on your application's behavior., Spring Boot in Action is a developer-focused guide to writing applications using Spring Boot. In it, you?ll learn how to bypass configuration steps so you can focus on your application?s behavior. Spring expert Craig Walls uses interesting and practical examples to teach you both how to use the default settings effectively and how to override and customize Spring Boot for your unique environment. Along the way, you?ll pick up insights from Craig?s years of Spring development experience.

Spring.Boot.in.Action.2015.12.pdf

Spring.Boot.in.Action.2015.12.pdfFor online information and ordering of this and other manning books, please visit www.manning.com.thepublisheroffersdiscountsonthisbookwhenorderedinquantity For more information, please contact Special sales department Manning publications co 20 Baldwin Road PO BoX 761 Shelter island. ny11964 Emailorders@manning.com @2016 by manning Publications Co. All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted,in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and manning Publications was aware of a trademark claim, the designations have been printed in initial caps ll Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine Manning publications co Development editor: Cynthia Kane 20 Baldwin Road Technical development editor: Robert casazza PO BoX 761 Copyeditor: Andy Carroll Shelter island. ny11964 Proofreader: Corbin Collins Technical p der John Guthrie Typesetter: Gordan Salinovic Cover designer: Marija Tudor ISBN9781617292545 Printed in the united states of america 12345678910-EBM-201918171615 contents reword vii pre eface 2x about this book xii acknowledgments xu Bootstarting Spring I 1. 1 Spring rebooted Taking a fresh look at spring 2. Examining spring Boot essentials 4 What Spring Boot isn't 7 1.2 Getting started with Spring boot 8 Installing the spring boot cli 8 Initializing a spring boot project with Spring Initializr 12 3 Summary 22 Developing your first Spring Boot application 23 2.1 Putting spring boot to work 24 Examining a newly initialized spring boot project 26 Dissecting Bc iect build 30 2.2 USing starter dependencies 33 Specifying facet-based dependencies 34. Overriding starter transitive dependencies 35 CONTENTS 2.8 USing automatic configuration 37 Focusing on application functionality 37. Running the application 45. What just happened? 45 2.4 Summary 48 Customizing configuration 49 8.1 Overriding Spring Boot auto-configuration 50 Securing the application 50. Creating a custom security configuration 51. Taking another peek under the covers of auto-configuration55 8.2 Externalizing configuration with properties 57 Fine-tuning auto-configuration 58. Externally configuring application beans 64. Configuring with profiles 69 8.8 Customizing application error pages 71 3.4 Summary 74 Testing with Spring Boot 76 4.1 Integration testing auto-configuration 77 4.2 Testing web applications 79 Mocking spring MvC 80- Testing web security 83 4.3 Testing a running application 86 Starting the server on a random port 87. Testing HTML pages with selenium 88 4.4 Summary 90 Getting Groovy with the spring Boot CLI 92 5.1 Developing a Spring Boot CLI application 93 Setting up the cli project 93 Eliminating code noise with Groovy 94. What just happened? 98 5.2 Grabbing dependencies 100 Overriding default dependency versions 101. Adding dependency repositories 102 5.8 Running tests with the CLI 102 5.4 Creating a deployable artifact 105 5.5 Summary 106 CONTENTS 6 Applying Grails in Spring Boot 107 1 Using gorm for data persistence 108 2 Defining views with groovy server pages 113 6.3 Mixing spring boot with grails 3 115 Creating a new grails project 116 Defining the domain 118 Writing a grails controller 119. Creating the view 120 6.4 Summary 123 Taking a peek inside with the Actuator 124 7.1 Exploring the actuator's endpoints 125 Viewing configuration details 126. Tapping runtime metrics 133 Shutting down the application 139. Fetching application information 140 7.2 Connecting to the Actuator remote shell 141 Viewing the autoconfig report 142. Listing application beans 143 Watching application metrics 144.Invoking actuator endpoints 145 7. 3 Monitoring your application with JMX 146 7.4 Customizing the Actuator 148 Changing endpoint Ds 148 Enabling and disabling endpoints 149 Adding custom metrics and gauges 149- Creating a custom trace repository 153 Plugging in custom health indicators 155 7.5 Securing Actuator endpoints 156 7.6 Summary 159 8 Deploying Spring Boot applications 160 8.1 Weighing deployment options 161 8.2 Deploying to an application server 162 Building a WaRfile 162 Creating a production profile Enabling database migration 168 8.3 Pushing to the cloud 173 Deploying to Cloud Foundry 173 Deploying to Heroku 177 8. Summary 180 appendix a spring Boot developer Tools 187 appendix b spring Boot starters 188 appendix c Configuration properties 195 appendix d spring boot dependencies 232 index 243 In the spring of 2014, the Delivery Engineering team at Netflix set out to achieve a lofty goal: enable end-to-end global continuous delivery via a software platform that facilitates both extensibility and resiliency. my team had previously built two different applications attempting to address Netflix's delivery and deployment needs, but both were beginning to show the telltale signs of monolith-ness and neither met the goals of flexibility and resiliency. What's more, the most stymieing effect of these monolithic applications was ultimately that we were unable to keep pace with our partner's inno- vation. Users had begun to move around our tools rather than with them It became apparent that if we wanted to provide real value to the company and rap- idly innovate, we needed to break up the monoliths into small, independent services that could be released at will. Embracing a microservice architecture gave us hope that we could also address the twin goals of flexibility and resiliency. but we needed to do it on a credible foundation where we could count on real concurrency, legitimate moni- toring, reliable and easy service discovery, and great runtime performance With the jVM as our bedrock, we looked for a framework that would give us rapid velocity and steadfast operationalization out of the box. We zeroed in on Spring Boot Spring Boot makes it effortless to create Spring-powered, production-ready ser- vices without a lot of code! Indeed, the fact that a simple Spring Boot Hello World application can fit into a tweet is a radical departure from what the same functionality required on the vm only a few short years ago. Out-of-the-box nonfunctional features like security, metrics, health-checks, embedded servers, and externalized configura tion made boot an easy choice for us FOREWORD Yet, when we embarked on our Spring boot journey solid documentation was hard to come by. Relying on source code isnt the most joyful manner of figuring out how to properly leverage a frameworks features It's not surprising to see the author of mannings venerable Spring in Action take on the challenge of concisely distilling the core aspects of working with Spring Boot into another cogent book. Nor is it surprising that Craig and the Manning crew have done another tremendously wonderful job! Spring Boot in Action is an easily readable book, as weve now come to expect from Craig and manning From chapter Is attention-getting introduction to Boot and the now legend ary 9Oish-character tweetable Boot application to an in-depth analysis of Boots Actuator in chapter 7, which enables a host of auto-magical operational features required for any production application, Spring Boot in Action leaves no stone unturned. Indeed, for me, chapter 7's deep dive into the Actuator answered some of the lingering questions I've had in the back of my head since picking up Boot well over a year ago. Chapter 8s thor- ough examination of deployment options opened my eyes to the simplicity of cloud Foundry for cloud deployments. One of my favorite chapters is chapter 4, where Craig explores the many powerful options for easily testing a Boot application. From the get- o, I was pleasantly surprised with some of Springs testing features, and boot takes g advantage of them nicely As I've publicly stated before, Spring Boot is just the kind of framework the Java community has been seeking for over a decade. Its easy-to-use development features and out-of-the-box operationalization make java development fun again I,m pleased to report that Spring and spring boot are the foundation of Netflix's new continuous delivery platform. What's more, other teams at Netflix are following the same path because they too see the myriad benefits of boot It's with equal parts excitement and passion that I absolutely endorse craigs book as the easy-to-digest and fun-to-read Spring boot documentation the Java community has been waiting for since Boot took the community by storm. Craigs accessible writ- ing style and sweeping analysis of boot's core features and functionality will surely leave readers with a solid grasp of Boot(along with a joyful sense of awe for it) Keep up the great work Craig Manning Publications, and all the brilliant develop ers who have made spring boot what it is today each one of you has ensured a bright future for the JV ANDREW GLOVER MANAGER, DELIVERY ENGINEERING AT NETFLIX preface At the 1964 New York World's Fair, Walt Disney introduced three groundbreaking attractions:"“it' s a small world,”“ Great Moments with mr. Lincoln," and the“ Carouse of Progress " All three of these attractions have since moved into disneyland and walt Disney world, and you can still see them today My favorite of these is the Carousel of Progress. Supposedly, it was one of Walt Disneys favorites too. It's part ride and part stage show where the seating area rotates around a center area featuring four stages. Each stage tells the story of a family at different time periods of the 20th century-the early 1900s, the 1920s the 1940s, and recent times-highlighting the technology advances in that time period The story of innovation is told from a hand-cranked washing machine, to electric lighting and radio, to automatic dishwashers and television, to computers and voice-activated appliances In every act, the father (who is also the narrator of the show)talks about the latest inventions and says "It cant get any better only to discover that in fact, it does get better in the next act as technology progresses Although Spring doesn't have quite as long a history as that displayed in the Car- ousel of Progress, I feel the same way about Spring as"Progress Dad felt about the 20th century. Each and every Spring application seems to make the lives of developers so much better. Just looking at how Spring components are declared and wired together, we can see the following progression over the history of Spring

Spring Boot实战学习笔记(三)

本文为学习Spring Boot实战的学习笔记,学习了一遍,但是好记性不如烂笔头,所以文章记录下来。图书购买地址为: https://item.jd.com/11894632.html.Spring Boot实战学习笔记1Spring Boot实战学习笔记2Spring Boot实战学习笔记3Spring Boot实战学习笔记4Spring Boot实战学习笔记51.Spring 基础2.Spri...

殘遛的博客 1007

避开奸商套路!手把手教你用Thaiphoon Burner和CPU-Z,一眼看穿内存SPD信息有没有被篡改

本文教你使用Thaiphoon Burner和CPU-Z工具,快速识别内存SPD信息是否被篡改,避免购买到虚标频率或假冒颗粒的内存条。通过详细步骤和实战案例,帮助用户掌握内存检测技巧,确保硬件购买的透明度和安全性。

weixin_32228501的博客 715

spring cloud jackson自定义文本转换器

由于 spring.jackson.default-property-inclusion 配置失效,所以得自定义文本转换器 废话不多说上代码 @Configuration @EnableWebMvc public class WebAppConfig implements WebMvcConfigurer { /** * 添加到消息转换器 * @param converters */ @Override public void conf

BabyLoveld的博客 1018

Mike 21如何制作随水深变化的糙率文件

MIKE 21如何制作随水深变化的糙率文件

zhuzhujiayoua的博客 2257

手把手教你做基于stm32的红外、语音、按键智能灯光控制(上)

这次项目使用的板子是stm32f103c8t6最小系统板,这个板子在tb上都能够买到,随便一个最小系统板都可以,== 注意在买最小系统板的时候需要买一个stlink下载器来下载程序。显示模块是使用的0.96英寸的OLED屏幕,注意是使用的IIC通信协议的OLED屏幕,不是使用SPI总线协议的。这次写的代码还顺便集成了检测温湿度的功能,所以要使用DHT11温湿度传感器,来采集温度。本文所设计的基于单片机的灯光控制系统主要由模式选择功能、手动模式和自动模式组成。LED灯自然就是要控制的部件了。

nbbskk的博客 6563

springboot使用actuator

序 最近有点空闲,回头来处理一些没有的注释,然后,是不是换换脑子,给springboot加点东西。几天来说说开启监控acuator的问题。不废话,看招。 一、maven引入jar <!-- actuator支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifa

zwrlj527的专栏 3763

【LaTex】LaTex的下载与安装(2025新手小白超详细、超简洁 Windows系统)

安装地点(1)texlive的安装:首先打开下载好的安装包,找到这个文件前面缺少了一页emm我去截取其他人的作为示范然后点击安装安装时间较久,大概要一个小时左右。具体要看个人电脑性能情况。如图显示如上图,则安装成功。图中是TeXstudio 4.8.7版本针对不同操作系统和使用场景的安装包 ,区别如下:(按需求下载)

爱学习的capoo的博客 5150

Spring Boot Actuator 深度实践:从健康检查到生产级可观测性

Spring Boot Actuator 是 Spring 生态中实现应用运行时可观测性的核心框架,其本质是基于 Micrometer 的标准化指标采集与端点暴露机制。它将 JVM 状态、线程堆栈、内存快照、环境配置等底层运行信息,统一抽象为可编程、可安全管控的 HTTP/JMX 端点。技术价值在于将传统依赖日志和调试的故障排查,升级为字段级权限控制、标签化指标查询与自动化诊断的能力。典型应用场景包括 GC 异常定位、内存泄漏取证、分布式锁竞争分析及微服务健康巡检。本文围绕 /actuator/health

hck341204的专栏 170

Redash离线环境部署2020.1(centos+windows)

背景 Redash是一款开源的BI系统,核心功能是添加数据源,然后进行数据的可视化展示。一般会拿出来同Supervisor和Metabase进行选型比较,这里对三者的选型不做细致分析。而是给出在Redash开发环境部署踩过的坑,很多坑是自己琢磨出来的,网上几乎找不到更新的资料。适用于没怎么用过linux,也不怎么熟悉python的,用的是最新(master)的redash的代码(上一个发布版本...

Jone_wan的专栏 2143

【AI智能体】Codex 浏览器操作自动化任务实战操作详解

【AI智能体】Codex 浏览器操作自动化任务实战操作详解

congge 4323

spring boot/cloud in action

maven依赖 <properties> <java.version>1.8</java.version> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-bo...

sdkdeveloper的博客 278

「PAT乙级真题解析」Basic Level 1034 有理数四则运算 (问题分析+完整步骤+伪代码描述+提交通过代码)

题设给定两个有理数, 要求输出这两个有理数的和、差、积、商。 如果只是这样, 则问题很简单, 但是题设要求输出的每个有理数必须是最简形式. **所以本题的一个重点是如何将有理数转为题设要求的有理数.**

过美好生活,做高效程序员 3134

Spring Boot与微服务面试核心考点解析

Spring Boot作为Java生态中的主流框架,其自动配置机制通过@Conditional注解和spring.factories(现为AutoConfiguration.imports)实现组件动态加载,大幅提升了开发效率。在微服务架构中,CAP理论是分布式系统的设计基石,不同注册中心如Eureka、ZooKeeper和Nacos根据场景选择AP或CP模式。服务熔断通过状态机转换保障系统可用性,而链路追踪技术如Sleuth+Zipkin则实现跨服务调用监控。本文基于大厂面试实战经验,深入解析Spring

weixin_30340819的博客 409

Imagiq AI-PQ 图像质量增强模块详解:联发科 ISP 中的 AI 图像管线实战解析

随着智能手机影像系统对图像质量要求的持续提升,联发科在其 Imagiq ISP 中引入了 AI 驱动的图像增强模块——AI-PQ(AI-based Picture Quality),通过 AI 模型对亮度、色彩、噪声、锐度等多个维度进行动态调节与增强,实现更加智能化和个性化的图像输出效果。AI-PQ 在实际工程中已成为影响照片风格、视频观感和多模组一致性的核心能力之一。本文围绕 Imagiq 平台最新一代 AI-PQ 模块(2024-2025年量产平台为基础),结合实机开发与调优经验,深入剖析其各子模块的算

努力分享一些人工智能、计算机视觉、影像等相关的知识干货! 1434

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

大厂Java面试技术栈:Spring Boot与分布式缓存实战

在Java开发领域,Spring Boot作为主流框架,其自动配置机制和启动流程是面试中的高频考点。理解SPI机制和@Conditional注解的工作原理,能帮助开发者实现自定义Starter的自动装载。分布式系统中,Redis作为关键组件,其缓存设计模式和分布式锁实现是区分开发者能力的重要指标。通过布隆过滤器防护缓存穿透,结合Redisson实现锁续期,能有效提升系统稳定性。这些技术在电商秒杀、金融交易等高并发场景中有广泛应用,掌握它们对通过大厂技术面试至关重要。

weixin_34167819的博客 594

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

大厂Java面试必考:Spring Boot与分布式缓存实战解析

在Java开发领域,Spring Boot作为快速构建单体应用的主流框架,其自动配置机制通过SpringFactoriesLoader实现条件化Bean加载,大幅提升了开发效率。分布式缓存则是应对高并发场景的核心技术,通过多级缓存架构和一致性协议解决性能瓶颈问题。这两种技术共同构成了现代Java工程师的核心能力矩阵,尤其在电商秒杀、实时交易等场景中,需要结合缓存雪崩防护、本地缓存协同等实战方案。从面试视角看,大厂对Spring Boot的考察聚焦自动配置原理与生产级特性,而分布式缓存则关注Redis架构设计

weixin_30500473的博客 349

深度学习工具包 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")

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Java面试必备:Spring Boot与Kafka核心技术解析

Spring Boot作为Java微服务开发的主流框架,其自动配置原理通过@EnableAutoConfiguration注解实现,大幅简化了传统Spring应用的配置复杂度。消息中间件Kafka则凭借其高吞吐、分布式特性成为异步通信的首选,其分区存储和零拷贝技术显著提升性能表现。在云原生架构中,这两项技术的组合能有效支撑高并发场景,如电商订单处理或实时日志分析。面试中常涉及Spring Boot自动配置实现、Kafka消费者组再平衡等核心机制,掌握这些原理对构建稳定可靠的分布式系统至关重要。通过分析典型面

weixin_33755649的博客 516

Spring Boot与Apache Doris实时数据分析实战指南

OLAP(在线分析处理)技术是现代数据分析的核心组件,通过列式存储和向量化执行引擎实现高性能查询。Apache Doris作为开源的MPP分析型数据库,结合其智能物化视图和实时数据摄入能力,能够有效解决TB/PB级数据的亚秒级响应需求。当与Spring Boot框架集成时,开发者可以快速构建高并发的数据服务API,实现从批量处理到实时分析的平滑过渡。这种组合特别适用于电商用户行为分析、实时报表生成等场景,实测能将分钟级查询优化至500ms内,同时支撑200+并发请求。通过JDBC连接池优化、Kafka实时摄

weixin_30387799的博客 336

Spring Boot项目化复习:从核心原理到工程实践的高效通关指南

在Java后端开发领域,Spring Boot作为构建微服务和企业级应用的主流框架,其核心价值在于通过“约定大于配置”的理念简化开发流程。理解其自动装配原理是掌握该框架的基石,它通过扫描类路径下的`spring.factories`文件,并利用一系列条件注解(如`@ConditionalOnClass`),实现了依赖的智能导入与Bean的自动化配置。这一机制极大地提升了开发效率,降低了项目启动的复杂性。在工程实践中,开发者常需集成如MyBatis、Redis、消息队列等关键技术组件,并处理多环境配置、打包部

weixin_34210740的博客 376
上一篇: 《Spring Boot in Action》【6. Grails】
下一篇: 《Spring Boot in Action》【8. 部署】
.NET跨平台
博客等级 码龄15年 6066粉丝 738原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值