当前位置: 首页 > news >正文

设计模式-Java

一、创建型模式

1. 单例模式

定义

确保一个类只有一个实例,并提供一个全局访问点。

实现方式

  • 饿汉式(线程安全,但可能浪费资源)

    public class Singleton {// 静态变量,类加载时初始化private static final Singleton instance = new Singleton();// 私有构造方法,防止外部实例化private Singleton() {}// 提供全局访问点public static Singleton getInstance() {return instance;}// 示例方法public void showMessage() {System.out.println("Hello from Singleton!");}
    }// 测试类
    public class TestSingleton {public static void main(String[] args) {Singleton singleton = Singleton.getInstance();singleton.showMessage();}
    }
    
  • 懒汉式(延迟加载,需考虑线程安全)

    public class Singleton {private static volatile Singleton instance;private Singleton() {}public static Singleton getInstance() {if (instance == null) {synchronized (Singleton.class) {if (instance == null) {instance = new Singleton();}}}return instance;}public void showMessage() {System.out.println("Hello from Lazy Singleton!");}
    }// 测试类
    public class TestSingleton {public static void main(String[] args) {Singleton singleton = Singleton.getInstance();singleton.showMessage();}
    }
    

应用场景

  • 数据库连接池。
  • 全局配置管理器。

2. 工厂模式

分类

  1. 简单工厂模式
    将对象的创建集中在一个工厂类中。

    public interface Shape {void draw();
    }public class Circle implements Shape {@Overridepublic void draw() {System.out.println("Drawing a circle");}
    }public class Rectangle implements Shape {@Overridepublic void draw() {System.out.println("Drawing a rectangle");}
    }public class ShapeFactory {public static Shape getShape(String type) {if ("circle".equalsIgnoreCase(type)) {return new Circle();} else if ("rectangle".equalsIgnoreCase(type)) {return new Rectangle();}return null;}
    }// 测试类
    public class TestFactory {public static void main(String[] args) {Shape shape1 = ShapeFactory.getShape("circle");shape1.draw();Shape shape2 = ShapeFactory.getShape("rectangle");shape2.draw();}
    }
    
  2. 工厂方法模式
    定义一个创建对象的接口,由子类决定实例化哪个类。

    public interface Shape {void draw();
    }public class Circle implements Shape {@Overridepublic void draw() {System.out.println("Drawing a circle");}
    }public abstract class ShapeFactory {public abstract Shape createShape();
    }public class CircleFactory extends ShapeFactory {@Overridepublic Shape createShape() {return new Circle();}
    }// 测试类
    public class TestFactoryMethod {public static void main(String[] args) {ShapeFactory factory = new CircleFactory();Shape shape = factory.createShape();shape.draw();}
    }
    
  3. 抽象工厂模式
    提供一个创建一系列相关或依赖对象的接口。

    public interface Button {void render();
    }public interface Checkbox {void render();
    }public class WindowsButton implements Button {@Overridepublic void render() {System.out.println("Rendering a Windows button");}
    }public class WindowsCheckbox implements Checkbox {@Overridepublic void render() {System.out.println("Rendering a Windows checkbox");}
    }public interface GUIFactory {Button createButton();Checkbox createCheckbox();
    }public class WindowsFactory implements GUIFactory {@Overridepublic Button createButton() {return new WindowsButton();}@Overridepublic Checkbox createCheckbox() {return new WindowsCheckbox();}
    }// 测试类
    public class TestAbstractFactory {public static void main(String[] args) {GUIFactory factory = new WindowsFactory();Button button = factory.createButton();button.render();Checkbox checkbox = factory.createCheckbox();checkbox.render();}
    }
    

应用场景

  • 动态创建对象(如 UI 组件、数据库驱动)。

3. 建造者模式

定义

将复杂对象的构建与其表示分离,使得同样的构建过程可以创建不同的表示。

实现方式

public class Computer {private String cpu;private String ram;private String storage;private Computer(Builder builder) {this.cpu = builder.cpu;this.ram = builder.ram;this.storage = builder.storage;}public static class Builder {private String cpu;private String ram;private String storage;public Builder setCpu(String cpu) {this.cpu = cpu;return this;}public Builder setRam(String ram) {this.ram = ram;return this;}public Builder setStorage(String storage) {this.storage = storage;return this;}public Computer build() {return new Computer(this);}}@Overridepublic String toString() {return "Computer{" +"cpu='" + cpu + '\'' +", ram='" + ram + '\'' +", storage='" + storage + '\'' +'}';}
}// 测试类
public class TestBuilder {public static void main(String[] args) {Computer computer = new Computer.Builder().setCpu("Intel i7").setRam("16GB").setStorage("512GB SSD").build();System.out.println(computer);}
}
应用场景
  • 构建复杂的对象(如 HTML 文档生成器、游戏角色创建器)。

4. 原型模式

定义

通过复制现有对象来创建新对象,而不是通过 new 创建。

实现方式

import java.util.Objects;public class Prototype implements Cloneable {private String data;public Prototype(String data) {this.data = data;}public String getData() {return data;}public void setData(String data) {this.data = data;}@Overrideprotected Object clone() throws CloneNotSupportedException {return super.clone();}@Overridepublic String toString() {return "Prototype{" +"data='" + data + '\'' +'}';}
}// 测试类
public class TestPrototype {public static void main(String[] args) throws CloneNotSupportedException {Prototype prototype = new Prototype("Original Data");Prototype clonedPrototype = (Prototype) prototype.clone();System.out.println("Original: " + prototype);System.out.println("Cloned: " + clonedPrototype);clonedPrototype.setData("Modified Data");System.out.println("After Modification:");System.out.println("Original: " + prototype);System.out.println("Cloned: " + clonedPrototype);}
}

应用场景

  • 需要频繁创建相似对象时(如游戏中的敌人克隆)。

二、结构型模式

1. 适配器模式

定义

将一个类的接口转换成客户希望的另一个接口,使原本不兼容的类可以一起工作。

实现方式

  • 类适配器(通过继承实现)

    public interface Target {void request();
    }public class Adaptee {public void specificRequest() {System.out.println("Specific Request");}
    }public class Adapter extends Adaptee implements Target {@Overridepublic void request() {specificRequest();}
    }// 测试类
    public class TestAdapter {public static void main(String[] args) {Target target = new Adapter();target.request();}
    }
    
  • 对象适配器(通过组合实现)

    public class Adapter implements Target {private Adaptee adaptee;public Adapter(Adaptee adaptee) {this.adaptee = adaptee;}@Overridepublic void request() {adaptee.specificRequest();}
    }// 测试类
    public class TestAdapter {public static void main(String[] args) {Adaptee adaptee = new Adaptee();Target target = new Adapter(adaptee);target.request();}
    }
    

应用场景

  • 第三方库与现有系统的集成。

2. 装饰者模式

定义

动态地为对象添加新的功能,而无需修改其原始代码。

实现方式

public interface Component {void operation();
}public class ConcreteComponent implements Component {@Overridepublic void operation() {System.out.println("Performing base operation");}
}public abstract class Decorator implements Component {protected Component component;public Decorator(Component component) {this.component = component;}@Overridepublic void operation() {component.operation();}
}public class ConcreteDecoratorA extends Decorator {public ConcreteDecoratorA(Component component) {super(component);}@Overridepublic void operation() {super.operation();addedBehavior();}private void addedBehavior() {System.out.println("Adding behavior A");}
}// 测试类
public class TestDecorator {public static void main(String[] args) {Component component = new ConcreteComponent();Component decoratedComponent = new ConcreteDecoratorA(component);decoratedComponent.operation();}
}

应用场景

  • 动态扩展功能(如 Java I/O 流中的 BufferedReaderFileReader)。

3. 代理模式

定义

为某个对象提供一个代理,以控制对该对象的访问。

实现方式

public interface Service {void doSomething();
}public class RealService implements Service {@Overridepublic void doSomething() {System.out.println("Executing real service");}
}public class ProxyService implements Service {private RealService realService;@Overridepublic void doSomething() {if (realService == null) {realService = new RealService();}System.out.println("Proxy: Before calling real service");realService.doSomething();System.out.println("Proxy: After calling real service");}
}// 测试类
public class TestProxy {public static void main(String[] args) {Service proxy = new ProxyService();proxy.doSomething();}
}

应用场景

  • 远程代理(如 RMI)。
  • 虚拟代理(如图片懒加载)。

4. 桥接模式

定义

将抽象部分与实现部分分离,使它们都可以独立变化。

实现方式

public interface Implementor {void operationImpl();
}public class ConcreteImplementorA implements Implementor {@Overridepublic void operationImpl() {System.out.println("Concrete Implementor A");}
}public abstract class Abstraction {protected Implementor implementor;public Abstraction(Implementor implementor) {this.implementor = implementor;}public abstract void operation();
}public class RefinedAbstraction extends Abstraction {public RefinedAbstraction(Implementor implementor) {super(implementor);}@Overridepublic void operation() {implementor.operationImpl();}
}// 测试类
public class TestBridge {public static void main(String[] args) {Implementor implementor = new ConcreteImplementorA();Abstraction abstraction = new RefinedAbstraction(implementor);abstraction.operation();}
}

应用场景

  • 多维度扩展(如不同形状和颜色的组合)。

三、行为型模式

1. 观察者模式

定义

定义了一种一对多的依赖关系,当一个对象的状态发生改变时,所有依赖于它的对象都会收到通知并自动更新。

实现方式

import java.util.ArrayList;
import java.util.List;public interface Observer {void update(String message);
}public class ConcreteObserver implements Observer {private String name;public ConcreteObserver(String name) {this.name = name;}@Overridepublic void update(String message) {System.out.println(name + " received: " + message);}
}public class Subject {private List<Observer> observers = new ArrayList<>();public void addObserver(Observer observer) {observers.add(observer);}public void notifyObservers(String message) {for (Observer observer : observers) {observer.update(message);}}
}// 测试类
public class TestObserver {public static void main(String[] args) {Subject subject = new Subject();Observer observer1 = new ConcreteObserver("Observer 1");Observer observer2 = new ConcreteObserver("Observer 2");subject.addObserver(observer1);subject.addObserver(observer2);subject.notifyObservers("New Message");}
}

应用场景

  • 订阅/发布系统(如消息队列、事件监听器)。

2. 生产者/消费者模式

定义

通过共享缓冲区实现生产者和消费者的解耦。

实现方式

import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;public class ProducerConsumer {private Queue<Integer> buffer = new LinkedList<>();private int capacity = 5;public synchronized void produce() throws InterruptedException {while (buffer.size() == capacity) {wait();}int value = new Random().nextInt(100);buffer.add(value);System.out.println("Produced: " + value);notifyAll();}public synchronized void consume() throws InterruptedException {while (buffer.isEmpty()) {wait();}int value = buffer.poll();System.out.println("Consumed: " + value);notifyAll();}
}// 测试类
public class TestProducerConsumer {public static void main(String[] args) {ProducerConsumer pc = new ProducerConsumer();Thread producerThread = new Thread(() -> {try {while (true) {pc.produce();Thread.sleep(1000);}} catch (InterruptedException e) {e.printStackTrace();}});Thread consumerThread = new Thread(() -> {try {while (true) {pc.consume();Thread.sleep(1000);}} catch (InterruptedException e) {e.printStackTrace();}});producerThread.start();consumerThread.start();}
}

应用场景

  • 消息队列。
  • 多线程任务调度。

3. 策略模式

定义

定义了一系列算法,并将每个算法封装起来,使它们可以互换。

实现方式

public interface Strategy {void execute();
}public class StrategyA implements Strategy {@Overridepublic void execute() {System.out.println("Executing Strategy A");}
}public class StrategyB implements Strategy {@Overridepublic void execute() {System.out.println("Executing Strategy B");}
}public class Context {private Strategy strategy;public void setStrategy(Strategy strategy) {this.strategy = strategy;}public void executeStrategy() {strategy.execute();}
}// 测试类
public class TestStrategy {public static void main(String[] args) {Context context = new Context();context.setStrategy(new StrategyA());context.executeStrategy();context.setStrategy(new StrategyB());context.executeStrategy();}
}

应用场景

  • 支付方式选择(如支付宝、微信支付)。

4. 模板方法模式

定义

定义一个操作中的算法骨架,而将一些步骤延迟到子类中。

实现方式

public abstract class Game {public final void play() {initialize();startPlay();endPlay();}protected abstract void initialize();protected abstract void startPlay();protected abstract void endPlay();
}public class Football extends Game {@Overrideprotected void initialize() {System.out.println("Football Game Initialized!");}@Overrideprotected void startPlay() {System.out.println("Football Game Started!");}@Overrideprotected void endPlay() {System.out.println("Football Game Finished!");}
}// 测试类
public class TestTemplateMethod {public static void main(String[] args) {Game game = new Football();game.play();}
}

应用场景

  • 固定流程的业务逻辑(如游戏开发、报表生成)。

5. 状态模式

定义

允许对象在其内部状态改变时改变其行为。

实现方式

public interface State {void handle();
}public class ConcreteStateA implements State {@Overridepublic void handle() {System.out.println("Handling state A");}
}public class ConcreteStateB implements State {@Overridepublic void handle() {System.out.println("Handling state B");}
}public class Context {private State state;public void setState(State state) {this.state = state;}public void request() {state.handle();}
}// 测试类
public class TestState {public static void main(String[] args) {Context context = new Context();context.setState(new ConcreteStateA());context.request();context.setState(new ConcreteStateB());context.request();}
}

应用场景

  • 不同状态下执行不同逻辑(如订单状态管理)。

相关文章:

设计模式-Java

一、创建型模式 1. 单例模式 定义 确保一个类只有一个实例&#xff0c;并提供一个全局访问点。 实现方式 饿汉式&#xff08;线程安全&#xff0c;但可能浪费资源&#xff09; public class Singleton {// 静态变量&#xff0c;类加载时初始化private static final Singlet…...

代码讲解系列-CV(五)——语义分割基础

文章目录 一、图像分割标注1.1 Labelme标注1.2 SAM辅助1.3 json格式 二、数据解析2.1 Dataset2.2 train.py2.2.1 取参2.2.2 分割和数据集的读取 三、Unet网络搭建3.1 Unet3.2 Network 四、损失函数和指标4.1 DICE系数4.2 损失函数4.3 半精度训练 五、SAM六、作业 语义分割是图片…...

在mfc中使用自定义三维向量类和计算多个三维向量的平均值

先添加一个普通类, Vector3.h, // Vector3.h: interface for the Vector3 class. // //#if !defined(AFX_VECTOR3_H__53D34D26_95FF_4377_BD54_57F4271918A4__INCLUDED_) #define AFX_VECTOR3_H__53D34D26_95FF_4377_BD54_57F4271918A4__INCLUDED_#if _MSC_VER > 1000 #p…...

RDMA ibverbs_API功能说明

设备管理 获取当前活动网卡 返回当前rdma设备列表 struct ibv_device **ibv_get_device_list(int *num_devices);//使用 struct ibv_device **dev_list ibv_get_device_list(NULL);获取网卡名 返回网卡名字字符串&#xff1a;如"mlx5_0"&#xff0c;一般通过网卡…...

【C++语言】string 类

一、为什么要学习 string 类 C语言中&#xff0c;字符串是以 “\0” 结尾的一些字符的集合&#xff0c;为了操作方便&#xff0c;C标准库中提供了一些 str 系列的库函数&#xff0c;但是这些库函数与字符串是分离开的&#xff0c;不太符合 OOP 的思想&#xff0c;而且底层空间需…...

快速上手gdb/cgdb

Linux调试器-gdb使用 1.背景2.调试原理、技巧命令2.1指令2.2 本质2.3 技巧 1.背景 程序的发布方式有两种&#xff0c;debug模式和release模式 Linux gcc/g出来的二进制程序&#xff0c;默认是release模式 要使用gdb调试&#xff0c;必须在源代码生成二进制程序的时候, 加上 -g…...

《养生》(二)

一、基础生活调整 1‌.作息规律‌ 固定每天7-8小时睡眠&#xff0c;尽量22:30前入睡&#xff0c;晨起后拉开窗帘晒太阳5分钟&#xff0c;调节生物钟‌ ‌2.饮食优化‌ 三餐定时&#xff0c;每餐细嚼慢咽20次以上&#xff0c;优先吃蔬菜和蛋白质&#xff08;如鸡蛋、豆腐&#x…...

JAVA:集成 Drools 业务规则引擎的技术指南

1、简述 Drools 是一个强大的业务规则引擎&#xff0c;适用于需要动态决策或规则管理的场景。它允许开发人员将业务逻辑与应用代码分离&#xff0c;使得业务人员可以通过规则文件维护和更新规则&#xff0c;而无需修改应用代码。本文将介绍 Drools 的基本概念、配置方式&#…...

GeoHD - 一种用于智慧城市热点探测的Python工具箱

GeoHD - 一种用于智慧城市热点探测的Python工具箱 详细原理请参考&#xff1a;Yan, Y., Quan, W., Wang, H., 2024. A data‐driven adaptive geospatial hotspot detection approach in smart cities. Trans. GIS tgis.13137. 代码下载&#xff1a;下载 1. 简介 在城市数据…...

记一次Ngnix配置

记一次Ngnix配置 配置Ngnix配置防火墙 假设一个服务器中有一个公网IP、一个内网IP&#xff0c;另外已经部署好后台服务的接口地址为http://内网ip:8088。 配置Ngnix 找到Ngnix的配置文件&#xff0c;通过在Ngnix的安装路径下的 \conf\nginx.conf 文件。 worker_processes 1;…...

2024年国赛高教杯数学建模C题农作物的种植策略解题全过程文档及程序

2024年国赛高教杯数学建模 C题 农作物的种植策略 原题再现 根据乡村的实际情况&#xff0c;充分利用有限的耕地资源&#xff0c;因地制宜&#xff0c;发展有机种植产业&#xff0c;对乡村经济的可持续发展具有重要的现实意义。选择适宜的农作物&#xff0c;优化种植策略&…...

java基础语知识(8)

类之间的关系 在类之间&#xff0c;最常见的关系有&#xff1a; 依赖&#xff08;“uses-a”&#xff09;;聚合&#xff08;“has-a”&#xff09;;继承&#xff08;“is-a”&#xff09;。 依赖&#xff1a;一种使用关系&#xff0c;即一个类的实现需要另一个类的协助&#x…...

室内定位精度方案对比

室内定位精度方案对比&#xff1a;成本、开发难度与精度的权衡 索引 引言 Wi-Fi 定位方案 定位原理 成本分析 开发难度 定位精度 蓝牙定位方案 定位原理 成本分析 开发难度 定位精度 超宽带&#xff08;UWB&#xff09;定位方案 定位原理 成本分析 开发难度 定…...

Pytorch深度学习教程_5_编写第一个神经网络

欢迎来到《pytorch深度学习教程》系列的第五篇&#xff01;在前面的四篇中&#xff0c;我们已经介绍了Python、numpy及pytorch的基本使用&#xff0c;并在上一个教程中介绍了梯度。今天&#xff0c;我们将探索神经网络&#xff0c;对于神经网络进行概述并进行简单的实践学习 欢…...

ImportError: cannot import name ‘FixtureDef‘ from ‘pytest‘

错误信息表明 pytest 在尝试导入 FixtureDef 时出现了问题。通常是由于 pytest 版本不兼容 或 插件版本冲突 引起的。以下是详细的排查步骤和解决方案&#xff1a; 1. 检查 pytest 版本 首先&#xff0c;确认当前安装的 pytest 版本。某些插件可能需要特定版本的 pytest 才能…...

改BUG:Mock测试的时候,when失效

问题再现&#xff1a; 这里我写了一测试用户注册接口的测试类&#xff0c;并通过when模拟下层的服务&#xff0c;但实际上when并没有奏效&#xff0c;还是走了真实的service层的逻辑。 package cn.ac.evo.review.test;import cn.ac.evo.review.user.UserMainApplication; imp…...

【自动化脚本工具】AutoHotkey (Windows)

目录 1. 介绍AutoHotkey2. 功能脚本集锦2.1 桌面键盘显示 1. 介绍AutoHotkey 支持Windows安装使用&#xff0c;下载地址为&#xff1a;https://www.autohotkey.com/ 2. 功能脚本集锦 2.1 桌面键盘显示 便于练习键盘盲打 脚本地址&#xff1a;https://blog.csdn.net/weixin_6…...

专题--Linux体系

Linux体系结构相关| ProcessOn免费在线作图,在线流程图,在线思维导图 ProcessOn是一个在线协作绘图平台&#xff0c;为用户提供强大、易用的作图工具&#xff01;支持在线创作流程图、思维导图、组织结构图、网络拓扑图、BPMN、UML图、UI界面原型设计、iOS界面原型设计等。同时…...

【DeepSeek】Mac m1电脑部署DeepSeek

一、电脑配置 个人电脑配置 二、安装ollama 简介&#xff1a;Ollama 是一个强大的开源框架&#xff0c;是一个为本地运行大型语言模型而设计的工具&#xff0c;它帮助用户快速在本地运行大模型&#xff0c;通过简单的安装指令&#xff0c;可以让用户执行一条命令就在本地运…...

Spring AI + Ollama 实现调用DeepSeek-R1模型API

一、前言 随着人工智能技术的飞速发展&#xff0c;大语言模型&#xff08;LLM&#xff09;在各个领域的应用越来越广泛。DeepSeek 作为一款备受瞩目的国产大语言模型&#xff0c;凭借其强大的自然语言处理能力和丰富的知识储备&#xff0c;迅速成为业界关注的焦点。无论是文本生…...

进程地址空间(比特课总结)

一、进程地址空间 1. 环境变量 1 &#xff09;⽤户级环境变量与系统级环境变量 全局属性&#xff1a;环境变量具有全局属性&#xff0c;会被⼦进程继承。例如当bash启动⼦进程时&#xff0c;环 境变量会⾃动传递给⼦进程。 本地变量限制&#xff1a;本地变量只在当前进程(ba…...

Linux相关概念和易错知识点(42)(TCP的连接管理、可靠性、面临复杂网络的处理)

目录 1.TCP的连接管理机制&#xff08;1&#xff09;三次握手①握手过程②对握手过程的理解 &#xff08;2&#xff09;四次挥手&#xff08;3&#xff09;握手和挥手的触发&#xff08;4&#xff09;状态切换①挥手过程中状态的切换②握手过程中状态的切换 2.TCP的可靠性&…...

2.Vue编写一个app

1.src中重要的组成 1.1main.ts // 引入createApp用于创建应用 import { createApp } from "vue"; // 引用App根组件 import App from ./App.vue;createApp(App).mount(#app)1.2 App.vue 其中要写三种标签 <template> <!--html--> </template>…...

MMaDA: Multimodal Large Diffusion Language Models

CODE &#xff1a; https://github.com/Gen-Verse/MMaDA Abstract 我们介绍了一种新型的多模态扩散基础模型MMaDA&#xff0c;它被设计用于在文本推理、多模态理解和文本到图像生成等不同领域实现卓越的性能。该方法的特点是三个关键创新:(i) MMaDA采用统一的扩散架构&#xf…...

Python爬虫(二):爬虫完整流程

爬虫完整流程详解&#xff08;7大核心步骤实战技巧&#xff09; 一、爬虫完整工作流程 以下是爬虫开发的完整流程&#xff0c;我将结合具体技术点和实战经验展开说明&#xff1a; 1. 目标分析与前期准备 网站技术分析&#xff1a; 使用浏览器开发者工具&#xff08;F12&…...

第一篇:Agent2Agent (A2A) 协议——协作式人工智能的黎明

AI 领域的快速发展正在催生一个新时代&#xff0c;智能代理&#xff08;agents&#xff09;不再是孤立的个体&#xff0c;而是能够像一个数字团队一样协作。然而&#xff0c;当前 AI 生态系统的碎片化阻碍了这一愿景的实现&#xff0c;导致了“AI 巴别塔问题”——不同代理之间…...

精益数据分析(97/126):邮件营销与用户参与度的关键指标优化指南

精益数据分析&#xff08;97/126&#xff09;&#xff1a;邮件营销与用户参与度的关键指标优化指南 在数字化营销时代&#xff0c;邮件列表效度、用户参与度和网站性能等指标往往决定着创业公司的增长成败。今天&#xff0c;我们将深入解析邮件打开率、网站可用性、页面参与时…...

使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台

🎯 使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台 📌 项目背景 随着大语言模型(LLM)的广泛应用,开发者常面临多个挑战: 各大模型(OpenAI、Claude、Gemini、Ollama)接口风格不统一;缺乏一个统一平台进行模型调用与测试;本地模型 Ollama 的集成与前…...

CVE-2020-17519源码分析与漏洞复现(Flink 任意文件读取)

漏洞概览 漏洞名称&#xff1a;Apache Flink REST API 任意文件读取漏洞CVE编号&#xff1a;CVE-2020-17519CVSS评分&#xff1a;7.5影响版本&#xff1a;Apache Flink 1.11.0、1.11.1、1.11.2修复版本&#xff1a;≥ 1.11.3 或 ≥ 1.12.0漏洞类型&#xff1a;路径遍历&#x…...

LLMs 系列实操科普(1)

写在前面&#xff1a; 本期内容我们继续 Andrej Karpathy 的《How I use LLMs》讲座内容&#xff0c;原视频时长 ~130 分钟&#xff0c;以实操演示主流的一些 LLMs 的使用&#xff0c;由于涉及到实操&#xff0c;实际上并不适合以文字整理&#xff0c;但还是决定尽量整理一份笔…...