SpringCloud学习笔记 - @SentinelResource的fallbackblockHandler配置详解 - sentinel

news2024/9/30 19:35:38

1. sentinel服务负载均衡测试

sentinel默认开启了负载均衡的轮询模式,为了测试sentinel服务负载均衡的效果,需要先创建两个服务提供者和一个服务消费者。

1.1. 分别创建两个服务提供者-支付服务9003、9004

1. 添加pom依赖: 提供者只需要将自己注册到服务注册中心即可,因此只需要添加spring-cloud-starter-alibaba-nacos-discovery。

	<dependencies>
        <!--自定义api-->
        <dependency>
            <groupId>com.atguigu.springboot</groupId>
            <artifactId>cloud-api-commons</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <!--nacos服务发现-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <!--springboot web-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <!--日常通用jar包-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

2. 编写yaml配置文件: 注意给两个服务分配不同的端口9003、9004

server:
  port: 9003

spring:
  application:
    name: nacos-payment-provider
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848

management:
  endpoints:
    web:
      exposure:
        include: "*"

3. 创建主启动类

@SpringBootApplication
@EnableDiscoveryClient
public class PaymentMain9003 {
    public static void main(String[] args) {
        SpringApplication.run(PaymentMain9003.class,args);
    }
}

4. 创建业务类

package com.atguigu.alibaba.controller;

import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author 强浩
 * @version 1.0.0
 * Copyright(c) YTANG All Rights Reserved
 * @className
 * @project 管理系统
 * @date 2022年09月14日
 */
@RestController
@Slf4j
public class PaymentController {
    @Value("${server.port}")
    private String serverPort;

    //模拟数据库
    public static HashMap<Long, Payment> hashMap = new HashMap<>();
    static {
        hashMap.put(1L, new Payment(1L,"28a8c1e3bc2742d8848569891fb42181"));
        hashMap.put(2L,new Payment(2L,"bba8c1e3bc2742d8848569891ac32182"));
        hashMap.put(3L,new Payment(3L,"6ua8c1e3bc2742d8848569891xt92183"));
    }

    //传入id获取数据
    @GetMapping(value = "/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id") Long id){
        Payment payment = hashMap.get(id);
        CommonResult<Payment> commonResult = new CommonResult(200, "from mysql,serverPort:  " + serverPort, payment);
        return commonResult;
    }
}

2. 创建服务消费者-订单服务84

1. 添加pom依赖: 因为之后需要使用sentinel进行限流,所以需要添加sentinel的依赖

    <dependencies>
        <dependency>
            <groupId>com.atguigu.springboot</groupId>
            <artifactId>cloud-api-commons</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

2. 配置application.yaml文件:

server:
  port: 84

spring:
  application:
    name: nacos-order-consumer
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
    sentinel:
      transport:
        dashboard: localhost:8080
        port: 8719

server_url:
  payment_provider: http://nacos-payment-provider

3. 创建主启动类:

@SpringBootApplication
@EnableDiscoveryClient
public class OrderMain84 {
    public static void main(String[] args) {
        SpringApplication.run(OrderMain84.class,args);
    }
}

4. 创建RestTemplate服务调用配置类:

package com.atgugui.alibaba.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author 强浩
 * @version 1.0.0
 * Copyright(c) YTANG All Rights Reserved
 * @className
 * @project 管理系统
 * @date 2022年09月14日
 */
@Configuration
public class ApplicationContextConfig {
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
}

5. 创建业务类: 注入RestTemplate进行远程服务调用

package com.atgugui.alibaba.controller;

import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author 强浩
 * @version 1.0.0
 * Copyright(c) YTANG All Rights Reserved
 * @className
 * @project 管理系统
 * @date 2022年09月14日
 */
@RestController
@Slf4j
public class CircleBreakerController {
    public static final String SERVER_URL = "http://nacos-payment-provider";

    @Resource
    private RestTemplate restTemplate;
    @GetMapping("/consumer/fallback/{id}")
    public CommonResult<Payment> fallback(@PathVariable("id") Long id){
        CommonResult<Payment> result = restTemplate.getForObject(SERVER_URL + "/paymentSQL/" + id, CommonResult.class, id);
        if(id == 4){
            throw new IllegalArgumentException ("IllegalArgumentException,非法参数异常....");
        }else if(result.getData() == null){
            throw new NullPointerException ("NullPointerException,该ID没有对应记录,空指针异常");
        }
        return result;
    }
}

5. 测试访问: 查看负载均衡的轮询效果
访问 http://localhost:84/consumer/fallback/1,多次访问,通过观察端口号可以发现,对支付服务进行了轮询访问。

2. fallback-业务错误处理

fallback只负责业务异常

1. 添加@SentinelResource注解,并配置fallback参数,指定服务降级处理方法

    @GetMapping("/consumer/fallback/{id}")
    @SentinelResource(value = "fallback", fallback = "handlerFallback")//指定fallback服务降级处理方法
    public CommonResult<Payment> fallback(@PathVariable("id") Long id){
        CommonResult<Payment> result = restTemplate.getForObject(SERVER_URL + "/paymentSQL/" + id, CommonResult.class, id);
        if(id == 4){
            throw new IllegalArgumentException ("IllegalArgumentException,非法参数异常....");
        }else if(result.getData() == null){
            throw new NullPointerException ("NullPointerException,该ID没有对应记录,空指针异常");
        }
        return result;
    }

    public CommonResult<Payment> handlerFallback(@PathVariable Long id,Throwable e){
        Payment payment = new Payment(id,"null");
        return new CommonResult<>(444,"兜底异常handlerFallback,exception内容  "+e.getMessage(),payment);
    }

2. 测试: http://localhost:84/consumer/fallback/5,在没有降级处理的时候会直接报错,添加了fallback后进入降级处理方法。
在这里插入图片描述

3. blockHandler-限流规则处理

blockHandler处理违反了限流规则的请求

1. 给fallback方法资源添加限流规则
在这里插入图片描述

2. 配置@SentinelResource的blockHandler参数指定流控服务降级方法

    @GetMapping("/consumer/fallback/{id}")
    @SentinelResource(value = "fallback", blockHandler = "blockHandler")
    public CommonResult<Payment> fallback(@PathVariable("id") Long id){
        CommonResult<Payment> result = restTemplate.getForObject(SERVER_URL + "/paymentSQL/" + id, CommonResult.class, id);
        if(id == 4){
            throw new IllegalArgumentException ("IllegalArgumentException,非法参数异常....");
        }else if(result.getData() == null){
            throw new NullPointerException ("NullPointerException,该ID没有对应记录,空指针异常");
        }
        return result;
    }

    public CommonResult<Payment> blockHandler(@PathVariable Long id, BlockException blockException){
        Payment payment = new Payment(id,"null");
        return new CommonResult<>(445,"blockHandler-sentinel限流,无此流水: blockException  "+blockException.getMessage(),payment);
    }

3. 测试:http://localhost:84/consumer/fallback/5
在这里插入图片描述

4. 服务熔断fallback和blockHandler同时配置

blockHandler和fallback 都进行了配置,则被限流降级而抛出BlockException时只会进入blockHandler处理逻辑。也就是说会优先处理服务限流,保证高可用,不要卡死服务器。

@RestController
@Slf4j
public class CircleBreakerController {
    public static final String SERVER_URL = "http://nacos-payment-provider";

    @Resource
    private RestTemplate restTemplate;
    @GetMapping("/consumer/fallback/{id}")
    @SentinelResource(value = "fallback", blockHandler = "blockHandler", fallback = "handlerFallback")
    public CommonResult<Payment> fallback(@PathVariable("id") Long id){
        CommonResult<Payment> result = restTemplate.getForObject(SERVER_URL + "/paymentSQL/" + id, CommonResult.class, id);
        if(id == 4){
            throw new IllegalArgumentException ("IllegalArgumentException,非法参数异常....");
        }else if(result.getData() == null){
            throw new NullPointerException ("NullPointerException,该ID没有对应记录,空指针异常");
        }
        return result;
    }
    public CommonResult handlerFallback(@PathVariable  Long id,Throwable e) {
        Payment payment = new Payment(id,"null");
        return new CommonResult<>(444,"兜底异常handlerFallback,exception内容  "+e.getMessage(),payment);
    }

    public CommonResult<Payment> blockHandler(@PathVariable Long id, BlockException blockException){
        Payment payment = new Payment(id,"null");
        return new CommonResult<>(445,"blockHandler-sentinel限流,无此流水: blockException  "+blockException.getMessage(),payment);
    }
}

5. exceptionsToIgnore忽略指定异常

@RestController
@Slf4j
public class CircleBreakerController {
    public static final String SERVER_URL = "http://nacos-payment-provider";

    @Resource
    private RestTemplate restTemplate;
    @GetMapping("/consumer/fallback/{id}")
    @SentinelResource(value = "fallback", blockHandler = "blockHandler", fallback = "handlerFallback",exceptionsToIgnore = IllegalArgumentException.class)
    public CommonResult<Payment> fallback(@PathVariable("id") Long id){
        CommonResult<Payment> result = restTemplate.getForObject(SERVER_URL + "/paymentSQL/" + id, CommonResult.class, id);
        if(id == 4){
            throw new IllegalArgumentException ("IllegalArgumentException,非法参数异常....");
        }else if(result.getData() == null){
            throw new NullPointerException ("NullPointerException,该ID没有对应记录,空指针异常");
        }
        return result;
    }
    public CommonResult handlerFallback(@PathVariable  Long id,Throwable e) {
        Payment payment = new Payment(id,"null");
        return new CommonResult<>(444,"兜底异常handlerFallback,exception内容  "+e.getMessage(),payment);
    }

    public CommonResult<Payment> blockHandler(@PathVariable Long id, BlockException blockException){
        Payment payment = new Payment(id,"null");
        return new CommonResult<>(445,"blockHandler-sentinel限流,无此流水: blockException  "+blockException.getMessage(),payment);
    }

}

设置了忽略IllegalArgumentException异常,当出现该异常时不会进入降级逻辑。
在这里插入图片描述

6. sentinel整合openFeign实现服务熔断降级

一般在消费端添加feign组件实现服务降级:在84消费端添加openFeign的依赖,实现服务的熔断降级。

1. 引入openFeign的pom依赖: 这里因为版本冲突问题,需要将devtools组件取消掉,目前具体冲突原因还不知道。

<dependencies>
        <dependency>
            <groupId>com.atguigu.springboot</groupId>
            <artifactId>cloud-api-commons</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <!--添加openFeign依赖-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
            <version>0.2.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <!--<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

2. 修改yaml文件,添加fegin对sentinel的支持:

server:
  port: 84

spring:
  application:
    name: nacos-order-consumer
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
    sentinel:
      transport:
        dashboard: localhost:8080
        port: 8719

server_url:
  payment_provider: http://nacos-payment-provider

feign:
  sentinel:
    enabled: true

3. 在主启动类开启openFeign:

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class OrderMain84 {
    public static void main(String[] args) {
        SpringApplication.run(OrderMain84.class,args);
    }
}

4. 编写业务类: 使用@FeignClient注解,指定要进行访问的微服务名称,和发生熔断时所要调用的fallback方法

@FeignClient(value = "nacos-payment-provider",fallback = PaymentFallbackServiceImpl.class)
public interface PaymentService {
    @GetMapping(value = "/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id") Long id);
}

5. 服务降级方法实现类: 相当于给PaymentService增加了一个实现类,在发生熔断的情况下自动调用方法的fallback实现,来快速返回结果,防止系统卡死。

@Service
public class PaymentFallbackServiceImpl implements PaymentService {
    @Override
    public CommonResult<Payment> paymentSQL(Long id) {
        return new CommonResult<>(44444,"服务降级返回,---PaymentFallbackService",new Payment(id,"errorSerial"));
    }
}

6. 现在就可以使用openFeign进行远程服务调用,我们只需要像之前一样将服务接口注入到controller层中,即可实现无感的远程服务调用了:

@RestController
@Slf4j
public class CircleBreakerController {
    //注入openFeign远程调用接口
    @Resource
    private PaymentService paymentService;

    @GetMapping(value = "/consumer/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id") Long id){
        CommonResult<Payment> result = paymentService.paymentSQL(id);
        return result;
    }
}

7. 测试: 访问 http://localhost:84/consumer/paymentSQL/2,此时将9003服务提供者断开,84消费侧自动降级,不会被耗死。
在这里插入图片描述

7. 各熔断框架比较

SentinelHystrixresilience4j
隔离策略信号量隔离(并发线程数限流)线程池隔商/信号量隔离信号量隔离
熔断降级策略基于响应时间、异常比率、异常数基于异常比率基于异常比率、响应时间
实时统计实现滑动窗口(LeapArray)滑动窗口(基于RxJava)Ring Bit Buffer
动态规则配置支持多种数据源支持多种数据源有限支持
拓展性多个扩展点插件的形式接口的形式
基于注解的支持支持支持支持
限流基于QPS,支持基于调用关系的限流有限的支持Rate Limiter
流量整形支持预热模式匀速器模式、预热排队模式不支持简单的Rate Limiter模式
系统自适应保护支持不支持不支持
控制台提供开箱即用的控制台,可配置规则、查看秒级监控,机器发观等简单的监控查看不提供控制台,可对接其它监控系统

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/353095.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

ElementUI中为什么使用this.$refs.form.validate验证成功却直接跳过

ElementUI中为什么使用this.$refs.form.validate验证成功却直接跳过 问题背景 在写一个Vue练手项目时&#xff0c;我使用rulse对表单中用户输入的数据进行校验&#xff0c;但莫名奇妙就发现&#xff1a;当我点击提交表单时&#xff0c;表单中的数据都验证成功了&#xff0c;但是…

SpringBoot分页实现

简介 分页功能是一个简单但必需的功能&#xff0c;在 SpringBoot 中分页实现非常的简单&#xff0c;有多种实现方式&#xff1b;主要和项目集成的持久层框架有关&#xff1b;这里主要介绍集成 MyBatis 和 SpringDataJpa 的分页实现 Mybatis - 使用 PageHelper 分页 首先在 p…

mybatis源码中一级和二级缓存分析

mybatis中,一级缓存的作用域为一个会话内; 二级缓存的作用域为全局的,可在多个会话中使用 1、一级缓存 [此处不讨论开启二级缓存的代码逻辑] 一级缓存的作用域在同一个事物中起作用。真正执行sql的是在 Executor&#xff1b;类图如下&#xff1b; 1.1、生成 Executor对象的…

玩转代码|使用acme.sh在Ubuntu配置Let’s Encrypt免费通配符SSL证书

&#x1f4e3;今日作品&#xff1a;使用acme.sh在Ubuntu配置Let’s Encrypt免费通配符SSL证书&#x1f466; 创作者&#xff1a;Jum朱⏰预计花费&#xff1a;10分钟&#x1f4d6;个人主页&#xff1a; Jum朱博客的个人主页acme.sh 是一款方便,强大的 Lets Encrypt 域名证书申请…

反射内存卡读写测试(RFM2gRead和RFM2gWrite)-- C++

一、函数介绍&#xff1a; 1.1 RFM2gWrite STDRFM2GCALL RFM2gWrite( RFM2GHANDLE rh, RFM2G_UINT32 Offset, void *Buffer, RFM2G_UINT32 Length ); 说明&#xff1a; RFM2gWrite()函数将一个或多个I/O数据缓冲区从应用程序传输到RFM2g节点&#xff0c;从指定的对齐内存偏…

InVEST模型 | 02 InVEST模型Python安装

InVEST在生态系统评估领域有着广泛的应用&#xff0c;由于其交互界面简洁直接&#xff0c;大大降低了模型的使用门槛。但当需要多次、多区域的运算时&#xff0c;手动点击的方法十分耗时费力&#xff0c;针对这样的情况&#xff0c;InVEST团队推出了natcap.invest接口&#xff…

Centos7部署Sonic前后端和Agent 端

前言 1、sonic介绍 Sonic是一款开源、支持分布式部署、在线自动化测试的私有云真机平台&#xff0c;Sonic官网地址 功能特性&#xff1a; Sonic架构&#xff1a; 2、准备工作 ①准备两台设备&#xff0c;并安装Centos系统&#xff0c;设备名称简称&#xff1a;设备1和设…

【Java】Java零基础第一节

Java.java 与 .class关于开发环境 - SDK第一个程序 - Hello worldJava程序理解 - Classes, New, Methods and Type.java 与 .class xxx.java文件&#xff1a; 存储的是人类语言可以看懂的高级语言(Language)&#xff0c;但是计算机不能看懂&#xff1b; xxx.class文件&#xf…

【YOLO V5】代码复现过程

接上篇&#xff0c;讲到如何从mask转成YOLOv5训练需要的txt数据集格式&#xff0c;这篇就在此基础上进行模型训练预测和部署转换吧&#xff01; 目录 1.环境准备 2.YOLO训练 2.1 数据集准备 2.2 data.yaml准备 2.3 yolov5.yaml准备 2.4 训练命令 3.YOLO预测 3.1OLOv5 P…

大猫盘 黑群晖 不用Docker 部署属于自己的聊天工具voceChat

引入 原因很简单我有个大猫盘&#xff0c;自己搞成了黑群&#xff0c;不支持Docker&#xff0c;我自己购买了域名&#xff0c;做了ddns解析&#xff0c;给群晖加了ssl证书&#xff0c;感觉既然数据安全了&#xff0c;服务也在自己家里能不能搭建一个自己的聊天软件&#xff0c…

windows下nvvp的基础使用1

windows下nvvp的基础使用1 cuda编程的重要帮手可视化工具nvvp 本来先写nsignt的使用方式,不过折腾了一会发现没弄得那么明白.先用着nvvp好了,毕竟只是先看书配合着写点简单的cuda代码而已 安装建议 在windows下安装cuda的话,也就那回事,自己可以参考一下搜索引擎 (win10安…

一次漏洞挖掘的简单组合拳

前言&#xff1a; 在最近的wxb举行hw中&#xff0c;同事让我帮他看看一些后台登录站点。尝试了未授权&#xff0c;弱口令皆无果&#xff0c;要么不存在弱口令&#xff0c;要么有验证码&#xff0c;没办法绕过。本文章仅提供一个思路&#xff0c;在hw中更多时候并不推荐尝试这种…

给正在注册或即将注册个体工商户营业执照的你

大家好&#xff0c;我是中国码农摘星人。 欢迎分享/收藏/赞/在看&#xff01; 作为程序员&#xff0c;平时除了主业&#xff0c;发展一些副业再正常不过。为了取得开展业务的合法性、合规性&#xff0c;以及后续的拓展&#xff0c;避免产生不必要的纠纷&#xff0c;这边就得注册…

ChatGPT真的会取代程序员吗?

程序员这两年被碰的瓷儿可不少啊&#xff0c;这架势不像是AI抢了程序员的饭碗&#xff0c;倒像是程序员抢了AI的饭碗一样...... 前两年低代码出来了&#xff0c;你们说程序员要被取代了&#xff0c;惹得大神们一顿输出&#xff1b;去年元宇宙出来了&#xff0c;你们又说程序员…

map相关接口(map接口、HashMap、LinkedHashMap、TreeMap)

Java知识点总结&#xff1a;想看的可以从这里进入 目录8.3、map结构8.3.1、 map接口8.3.2、HashMap8.3.3、LinkedHashMap8.3.4、TreeMap8.3、map结构 8.3.1、 map接口 map的集合是以键值对的形式存在的 (key-value)&#xff0c;每个键只能对应一个值&#xff0c;通常通过键去…

什么表单设计工具能快速提升办公效率?

在信息化快速发展的年代&#xff0c;谁能掌握更先进的技术&#xff0c;谁就能拥有更广阔的发展前景。在以前的办公环境中&#xff0c;传统的表单制作工具占据了主流地位&#xff0c;随着办公自动化的快速发展&#xff0c;传统表单工具的弊端也暴露出来了&#xff0c;采用更先进…

m0n0wall防火墙(10)

实验目的 1、深入理解防火墙的功能和工作原理&#xff1b; 2、熟悉软件防火墙&#xff0c;掌握m0n0防火墙的规则和配置。预备知识 m0n0wall M0n0wall是基于FreeBSD内核开发的免费软件防火墙。m0n0wall提供基于web的配置管理、提供VPN功能、支持DHCP Server、DNS转发、动态DNS…

maddpg 复现过程中遇到的问题

最近在复现论文Multi-Agent Actor-Critic for Mixed Cooperative-Competitive Environments https://github.com/openai/multiagent-particle-envshttps://github.com/philtabor/Multi-Agent-Deep-Deterministic-Policy-Gradients.gitGitHub - philtabor/Multi-Agent-Deep-Dete…

windows配置c语言编译系统-wingw gcc cmake

前言 笔者在做嵌入式mcu编程的时候&#xff0c;有时候想要验证一下部分代码的功能&#xff0c;需要先编译成bin文件&#xff0c;然后烧录到mcu内执行。每次编译烧录运行耗时较久。于是想到是不是可以在电脑上配置一个c的编译环境&#xff0c;来验证一些与硬件不相干的代码。验…

idea多时编辑多行-winmac都支持

1背景介绍 idea编辑器非常强大&#xff0c;其中一个功能非常优秀&#xff0c;很多程序员也非常喜欢用。这个功能能够大大大提高工作效率-------------多行代码同时编辑 2win 2.1方法1 按住alt鼠标左键上/下拖动即可 这样选中多行后&#xff0c;可以直接多行编辑。 优点&a…