SpringBoot中10种动态修改配置的方法

在SpringBoot应用中,配置信息通常通过application.propertiesapplication.yml文件静态定义,应用启动后这些配置就固定下来了。

但我们常常需要在不重启应用的情况下动态修改配置,以实现灰度发布、A/B测试、动态调整线程池参数、切换功能开关等场景。

本文将介绍SpringBoot中10种实现配置动态修改的方法。

1. @RefreshScope结合Actuator刷新端点

Spring Cloud提供的@RefreshScope注解是实现配置热刷新的基础方法。

实现步骤

  1. 添加依赖:
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter</artifactId>
</dependency>
  1. 开启刷新端点:
management.endpoints.web.exposure.include=refresh
  1. 给配置类添加@RefreshScope注解:
@RefreshScope
@RestController
public class ConfigController {@Value("${app.message:Default message}")private String message;@GetMapping("/message")public String getMessage() {return message;}
}
  1. 修改配置后,调用刷新端点:
curl -X POST http://localhost:8080/actuator/refresh

优缺点

优点

  • 实现简单,利用Spring Cloud提供的现成功能
  • 无需引入额外的配置中心

缺点

  • 需要手动触发刷新
  • 只能刷新单个实例,在集群环境中需要逐个调用
  • 只能重新加载配置源中的值,无法动态添加新配置

2. Spring Cloud Config配置中心

Spring Cloud Config提供了一个中心化的配置服务器,支持配置文件的版本控制和动态刷新。

实现步骤

  1. 设置Config Server:
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-server</artifactId>
</dependency>
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {public static void main(String[] args) {SpringApplication.run(ConfigServerApplication.class, args);}
}
spring.cloud.config.server.git.uri=https://github.com/your-repo/config
  1. 客户端配置:
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
# bootstrap.properties
spring.application.name=my-service
spring.cloud.config.uri=http://localhost:8888
  1. 添加自动刷新支持:
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>

优缺点

优点

  • 提供配置的版本控制
  • 支持配置的环境隔离
  • 通过Spring Cloud Bus可实现集群配置的自动刷新

缺点

  • 引入了额外的基础设施复杂性
  • 依赖额外的消息总线实现集群刷新
  • 配置更新有一定延迟

3. 基于数据库的配置存储

将配置信息存储在数据库中,通过定时任务或事件触发机制实现配置刷新。

实现方案

  1. 创建配置表:
CREATE TABLE app_config (config_key VARCHAR(100) PRIMARY KEY,config_value VARCHAR(500) NOT NULL,description VARCHAR(200),update_time TIMESTAMP
);
  1. 实现配置加载和刷新:
@Service
public class DatabaseConfigService {@Autowiredprivate JdbcTemplate jdbcTemplate;private Map<String, String> configCache = new ConcurrentHashMap<>();@PostConstructpublic void init() {loadAllConfig();}@Scheduled(fixedDelay = 60000)  // 每分钟刷新public void loadAllConfig() {List<Map<String, Object>> rows = jdbcTemplate.queryForList("SELECT config_key, config_value FROM app_config");for (Map<String, Object> row : rows) {configCache.put((String) row.get("config_key"), (String) row.get("config_value"));}}public String getConfig(String key, String defaultValue) {return configCache.getOrDefault(key, defaultValue);}
}

优缺点

优点

  • 简单直接,无需额外组件
  • 可以通过管理界面实现配置可视化管理
  • 配置持久化,重启不丢失

缺点

  • 刷新延迟取决于定时任务间隔
  • 数据库成为潜在的单点故障
  • 需要自行实现配置的版本控制和权限管理

4. 使用ZooKeeper管理配置

利用ZooKeeper的数据变更通知机制,实现配置的实时动态更新。

实现步骤

  1. 添加依赖:
<dependency><groupId>org.apache.curator</groupId><artifactId>curator-recipes</artifactId><version>5.1.0</version>
</dependency>
  1. 实现配置监听:
@Component
public class ZookeeperConfigManager {private final CuratorFramework client;private final Map<String, String> configCache = new ConcurrentHashMap<>();@Autowiredpublic ZookeeperConfigManager(CuratorFramework client) {this.client = client;initConfig();}private void initConfig() {try {String configPath = "/config";if (client.checkExists().forPath(configPath) == null) {client.create().creatingParentsIfNeeded().forPath(configPath);}List<String> keys = client.getChildren().forPath(configPath);for (String key : keys) {String fullPath = configPath + "/" + key;byte[] data = client.getData().forPath(fullPath);configCache.put(key, new String(data));// 添加监听器NodeCache nodeCache = new NodeCache(client, fullPath);nodeCache.getListenable().addListener(() -> {byte[] newData = nodeCache.getCurrentData().getData();configCache.put(key, new String(newData));System.out.println("Config updated: " + key + " = " + new String(newData));});nodeCache.start();}} catch (Exception e) {throw new RuntimeException("Failed to initialize config from ZooKeeper", e);}}public String getConfig(String key, String defaultValue) {return configCache.getOrDefault(key, defaultValue);}
}

优缺点

优点

  • 实时通知,配置变更后立即生效
  • ZooKeeper提供高可用性保证
  • 适合分布式环境下的配置同步

缺点

  • 需要维护ZooKeeper集群
  • 配置管理不如专用配置中心直观
  • 存储大量配置时性能可能受影响

5. Redis发布订阅机制实现配置更新

利用Redis的发布订阅功能,实现配置变更的实时通知。

实现方案

  1. 添加依赖:
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
  1. 实现配置刷新监听:
@Component
public class RedisConfigManager {@Autowiredprivate StringRedisTemplate redisTemplate;private final Map<String, String> configCache = new ConcurrentHashMap<>();@PostConstructpublic void init() {loadAllConfig();subscribeConfigChanges();}private void loadAllConfig() {Set<String> keys = redisTemplate.keys("config:*");if (keys != null) {for (String key : keys) {String value = redisTemplate.opsForValue().get(key);configCache.put(key.replace("config:", ""), value);}}}private void subscribeConfigChanges() {redisTemplate.getConnectionFactory().getConnection().subscribe((message, pattern) -> {String[] parts = new String(message.getBody()).split("=");if (parts.length == 2) {configCache.put(parts[0], parts[1]);}},"config-channel".getBytes());}public String getConfig(String key, String defaultValue) {return configCache.getOrDefault(key, defaultValue);}// 更新配置的方法(管理端使用)public void updateConfig(String key, String value) {redisTemplate.opsForValue().set("config:" + key, value);redisTemplate.convertAndSend("config-channel", key + "=" + value);}
}

优缺点

优点

  • 实现简单,利用Redis的发布订阅机制
  • 集群环境下配置同步实时高效
  • 可以与现有Redis基础设施集成

缺点

  • 依赖Redis的可用性
  • 需要确保消息不丢失
  • 缺乏版本控制和审计功能

6. 自定义配置加载器和监听器

通过自定义Spring的PropertySource和文件监听机制,实现本地配置文件的动态加载。

实现方案

@Component
public class DynamicPropertySource implements ApplicationContextAware {private static final Logger logger = LoggerFactory.getLogger(DynamicPropertySource.class);private ConfigurableApplicationContext applicationContext;private File configFile;private Properties properties = new Properties();private FileWatcher fileWatcher;@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {this.applicationContext = (ConfigurableApplicationContext) applicationContext;try {configFile = new File("config/dynamic.properties");if (configFile.exists()) {loadProperties();registerPropertySource();startFileWatcher();}} catch (Exception e) {logger.error("Failed to initialize dynamic property source", e);}}private void loadProperties() throws IOException {try (FileInputStream fis = new FileInputStream(configFile)) {properties.load(fis);}}private void registerPropertySource() {MutablePropertySources propertySources = applicationContext.getEnvironment().getPropertySources();PropertiesPropertySource propertySource = new PropertiesPropertySource("dynamic", properties);propertySources.addFirst(propertySource);}private void startFileWatcher() {fileWatcher = new FileWatcher(configFile);fileWatcher.setListener(new FileChangeListener() {@Overridepublic void fileChanged() {try {Properties newProps = new Properties();try (FileInputStream fis = new FileInputStream(configFile)) {newProps.load(fis);}// 更新已有属性MutablePropertySources propertySources = applicationContext.getEnvironment().getPropertySources();PropertiesPropertySource oldSource = (PropertiesPropertySource) propertySources.get("dynamic");if (oldSource != null) {propertySources.replace("dynamic", new PropertiesPropertySource("dynamic", newProps));}// 发布配置变更事件applicationContext.publishEvent(new EnvironmentChangeEvent(Collections.singleton("dynamic")));logger.info("Dynamic properties reloaded");} catch (Exception e) {logger.error("Failed to reload properties", e);}}});fileWatcher.start();}// 文件监听器实现(简化版)private static class FileWatcher extends Thread {private final File file;private FileChangeListener listener;private long lastModified;public FileWatcher(File file) {this.file = file;this.lastModified = file.lastModified();}public void setListener(FileChangeListener listener) {this.listener = listener;}@Overridepublic void run() {try {while (!Thread.interrupted()) {long newLastModified = file.lastModified();if (newLastModified != lastModified) {lastModified = newLastModified;if (listener != null) {listener.fileChanged();}}Thread.sleep(5000);  // 检查间隔}} catch (InterruptedException e) {// 线程中断}}}private interface FileChangeListener {void fileChanged();}
}

优缺点

优点

  • 不依赖外部服务,完全自主控制
  • 可以监控本地文件变更实现实时刷新
  • 适合单体应用或简单场景

缺点

  • 配置分发需要额外机制支持
  • 集群环境下配置一致性难以保证
  • 需要较多自定义代码

7. Apollo配置中心

携程开源的Apollo是一个功能强大的分布式配置中心,提供配置修改、发布、回滚等完整功能。

实现步骤

  1. 添加依赖:
<dependency><groupId>com.ctrip.framework.apollo</groupId><artifactId>apollo-client</artifactId><version>2.0.1</version>
</dependency>
  1. 配置Apollo客户端:
# app.properties
app.id=your-app-id
apollo.meta=http://apollo-config-service:8080
  1. 启用Apollo:
@SpringBootApplication
@EnableApolloConfig
public class Application {public static void main(String[] args) {SpringApplication.run(Application.class, args);}
}
  1. 使用配置:
@Component
public class SampleService {@Value("${timeout:1000}")private int timeout;// 监听特定配置变更@ApolloConfigChangeListenerpublic void onConfigChange(ConfigChangeEvent event) {if (event.isChanged("timeout")) {ConfigChange change = event.getChange("timeout");System.out.println("timeout changed from " + change.getOldValue() + " to " + change.getNewValue());// 可以在这里执行特定逻辑,如重新初始化线程池等}}
}

优缺点

优点

  • 提供完整的配置管理界面
  • 支持配置的灰度发布
  • 具备权限控制和操作审计
  • 集群自动同步,无需手动刷新

缺点

  • 需要部署和维护Apollo基础设施
  • 学习成本相对较高
  • 小型项目可能过于重量级

8. Nacos配置管理

阿里开源的Nacos既是服务发现组件,也是配置中心,广泛应用于Spring Cloud Alibaba生态。

实现步骤

  1. 添加依赖:
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
  1. 配置Nacos:
# bootstrap.properties
spring.application.name=my-service
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
# 支持多配置文件
spring.cloud.nacos.config.extension-configs[0].data-id=database.properties
spring.cloud.nacos.config.extension-configs[0].group=DEFAULT_GROUP
spring.cloud.nacos.config.extension-configs[0].refresh=true
  1. 使用配置:
@RestController
@RefreshScope
public class ConfigController {@Value("${useLocalCache:false}")private boolean useLocalCache;@GetMapping("/cache")public boolean getUseLocalCache() {return useLocalCache;}
}

优缺点

优点

  • 与Spring Cloud Alibaba生态无缝集成
  • 配置和服务发现功能二合一
  • 轻量级,易于部署和使用
  • 支持配置的动态刷新和监听

缺点

  • 部分高级功能不如Apollo丰富
  • 需要额外维护Nacos服务器
  • 需要使用bootstrap配置机制

9. Spring Boot Admin与Actuator结合

Spring Boot Admin提供了Web UI来管理和监控Spring Boot应用,结合Actuator的环境端点可以实现配置的可视化管理。

实现步骤

  1. 设置Spring Boot Admin服务器:
<dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-server</artifactId><version>2.7.0</version>
</dependency>
@SpringBootApplication
@EnableAdminServer
public class AdminServerApplication {public static void main(String[] args) {SpringApplication.run(AdminServerApplication.class, args);}
}
  1. 配置客户端应用:
<dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-client</artifactId><version>2.7.0</version>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
spring.boot.admin.client.url=http://localhost:8080
management.endpoints.web.exposure.include=*
management.endpoint.env.post.enabled=true
  1. 通过Spring Boot Admin UI修改配置

Spring Boot Admin提供UI界面,可以查看和修改应用的环境属性。通过发送POST请求到/actuator/env端点修改配置。

优缺点

优点

  • 提供可视化操作界面
  • 与Spring Boot自身监控功能集成
  • 无需额外的配置中心组件

缺点

  • 修改的配置不持久化,应用重启后丢失
  • 安全性较弱,需要额外加强保护
  • 不适合大规模生产环境的配置管理

10. 使用@ConfigurationProperties结合EventListener

利用Spring的事件机制和@ConfigurationProperties绑定功能,实现配置的动态更新。

实现方案

  1. 定义配置属性类:
@Component
@ConfigurationProperties(prefix = "app")
@Setter
@Getter
public class ApplicationProperties {private int connectionTimeout;private int readTimeout;private int maxConnections;private Map<String, String> features = new HashMap<>();// 初始化客户端的方法public HttpClient buildHttpClient() {return HttpClient.newBuilder().connectTimeout(Duration.ofMillis(connectionTimeout)).build();}
}
  1. 添加配置刷新机制:
@Component
@RequiredArgsConstructor
public class ConfigRefresher {private final ApplicationProperties properties;private final ApplicationContext applicationContext;private HttpClient httpClient;@PostConstructpublic void init() {refreshHttpClient();}@EventListener(EnvironmentChangeEvent.class)public void onEnvironmentChange() {refreshHttpClient();}private void refreshHttpClient() {httpClient = properties.buildHttpClient();System.out.println("HttpClient refreshed with timeout: " + properties.getConnectionTimeout());}public HttpClient getHttpClient() {return this.httpClient;}// 手动触发配置刷新的方法public void refreshProperties(Map<String, Object> newProps) {PropertiesPropertySource propertySource = new PropertiesPropertySource("dynamic", convertToProperties(newProps));ConfigurableEnvironment env = (ConfigurableEnvironment) applicationContext.getEnvironment();env.getPropertySources().addFirst(propertySource);// 触发环境变更事件applicationContext.publishEvent(new EnvironmentChangeEvent(newProps.keySet()));}private Properties convertToProperties(Map<String, Object> map) {Properties properties = new Properties();for (Map.Entry<String, Object> entry : map.entrySet()) {properties.put(entry.getKey(), entry.getValue().toString());}return properties;}
}

优缺点

优点

  • 强类型的配置绑定
  • 利用Spring内置机制,无需额外组件
  • 灵活性高,可与其他配置源结合

缺点

  • 需要编写较多代码
  • 配置变更通知需要额外实现
  • 不适合大规模或跨服务的配置管理

方法比较与选择指南

方法易用性功能完整性适用规模实时性
@RefreshScope+Actuator★★★★★★★小型手动触发
Spring Cloud Config★★★★★★★中大型需配置
数据库存储★★★★★★★中型定时刷新
ZooKeeper★★★★★★中型实时
Redis发布订阅★★★★★★★中型实时
自定义配置加载器★★★★★小型定时刷新
Apollo★★★★★★★★中大型实时
Nacos★★★★★★★★中大型实时
Spring Boot Admin★★★★★★小型手动触发
@ConfigurationProperties+事件★★★★★★小型事件触发

总结

动态配置修改能够提升系统的灵活性和可管理性,选择合适的动态配置方案应综合考虑应用规模、团队熟悉度、基础设施现状和业务需求。

无论选择哪种方案,确保配置的安全性、一致性和可追溯性都是至关重要的。

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

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

相关文章

嵌入式自学第二十二天(5.15)

顺序表和链表 优缺点 存储方式&#xff1a; 顺序表是一段连续的存储单元 链表是逻辑结构连续物理结构&#xff08;在内存中的表现形式&#xff09;不连续 时间性能&#xff0c; 查找顺序表O(1)&#xff1a;下标直接查找 链表 O(n)&#xff1a;从头指针往后遍历才能找到 插入和…

高并发内存池(三):TLS无锁访问以及Central Cache结构设计

目录 前言&#xff1a; 一&#xff0c;thread cache线程局部存储的实现 问题引入 概念说明 基本使用 thread cache TLS的实现 二&#xff0c;Central Cache整体的结构框架 大致结构 span结构 span结构的实现 三&#xff0c;Central Cache大致结构的实现 单例模式 thr…

Ubuntu 安装 Docker(镜像加速)完整教程

Docker 是一款开源的应用容器引擎&#xff0c;允许开发者打包应用及其依赖包到一个轻量级、可移植的容器中。本文将介绍在 Ubuntu 系统上安装 Docker 的步骤。 1. 更新软件源 首先&#xff0c;更新 Ubuntu 系统的软件源&#xff1a; sudo apt update2. 安装基本软件 接下来…

【深度学习】数据集的划分比例到底是选择811还是712?

1 引入 在机器学习中&#xff0c;将数据集划分为训练集&#xff08;Training Set&#xff09;、验证集&#xff08;Validation Set&#xff09;和测试集&#xff08;Test Set&#xff09;是非常标准的步骤。这三个集合各有其用途&#xff1a; 训练集 (Training Set)&#xff…

Mysql刷题 day01

LC 197 上升的温度 需求&#xff1a;编写解决方案&#xff0c;找出与之前&#xff08;昨天的&#xff09;日期相比温度更高的所有日期的 id 。 代码&#xff1a; select w2.id from Weather as w1 join Weather as w2 on DateDiff(w2.recordDate , w1.recordDate) 1 where…

鸿蒙OSUniApp 制作个人信息编辑界面与头像上传功能#三方框架 #Uniapp

UniApp 制作个人信息编辑界面与头像上传功能 前言 最近在做一个社交类小程序时&#xff0c;遇到了需要实现用户资料编辑和头像上传的需求。这个功能看似简单&#xff0c;但要做好用户体验和兼容多端&#xff0c;还是有不少细节需要处理。经过一番摸索&#xff0c;总结出了一套…

科技的成就(六十八)

623、杰文斯悖论 杰文斯悖论是1865年经济学家威廉斯坦利杰文斯提出的一悖论&#xff1a;当技术进步提高了效率&#xff0c;资源消耗不仅没有减少&#xff0c;反而激增。例如&#xff0c;瓦特改良的蒸汽机让煤炭燃烧更加高效&#xff0c;但结果却是煤炭需求飙升。 624、代码混…

荣耀手机,系统MagicOS 9.0 USB配置没有音频来源后无法被adb检测到,无法真机调试的解决办法

荣耀手机&#xff0c;系统MagicOS 9.0 USB配置没有音频来源后无法被adb检测到&#xff0c;无法真机调试的解决办法 前言环境说明操作方法 前言 一直在使用的uni-app真机运行荣耀手机方法&#xff0c;都是通过设置USB配置的音频来源才能成功。突然&#xff0c;因为我的手机的系…

D-Pointer(Pimpl)设计模式(指向实现的指针)

Qt 的 D-Pointer&#xff08;Pimpl&#xff09;设计模式 1. Pimpl 模式简介 Pimpl&#xff08;Pointer to Implementation&#xff09;是一种设计模式&#xff0c;用于将类的接口与实现分离&#xff0c;从而隐藏实现细节&#xff0c;降低编译依赖&#xff0c;提高代码的可维护…

MySQL 8.0 OCP 1Z0-908 101-110题

Q101.which two queries are examples of successful SQL injection attacks? A.SELECT id, name FROM backup_before WHERE name‘; DROP TABLE injection; --’; B. SELECT id, name FROM user WHERE id23 oR id32 OR 11; C. SELECT id, name FROM user WHERE user.id (SEL…

Vue ElementUI原生upload修改字体大小和区域宽度

Vue ElementUI原生upload修改字体大小和区域宽度 修改后 代码 新增的修改样式代码 .upload-demo /deep/ .el-upload-dragger{width: 700px;height: 300px; }原有拖拽组件代码 <!-- 拖拽上传组件 --><el-uploadclass"upload-demo"dragaction"":m…

React和Vue在前端开发中, 通常选择哪一个

React和Vue的选择需结合具体需求&#xff1a; 选React的场景 大型企业级应用&#xff0c;需处理复杂状态&#xff08;如电商、社交平台&#xff09;团队熟悉JavaScript&#xff0c;已有React技术栈积累需要高度灵活的架构&#xff08;React仅专注视图层&#xff0c;可自由搭配…

Python爬虫实战:研究源码还原技术,实现逆向解密

1. 引言 在网络爬虫技术实际应用中,目标网站常采用各种加密手段保护数据传输和业务逻辑。传统逆向解密方法依赖人工分析和调试,效率低下且易出错。随着 Web 应用复杂度提升,特别是 JavaScript 混淆技术广泛应用,传统方法面临更大挑战。 本文提出基于源码还原的逆向解密方法…

什么是alpaca 或 sharegpt 格式的数据集?

环境&#xff1a; LLaMA-Factory 问题描述&#xff1a; alpaca 或 sharegpt 格式的数据集&#xff1f; 解决方案&#xff1a; “Alpaca”和“ShareGPT”格式的数据集&#xff0c;是近年来在开源大语言模型微调和对话数据构建领域比较流行的两种格式。它们主要用于训练和微调…

OpenCV CUDA模块中矩阵操作------矩阵元素求和

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 算法描述 在OpenCV的CUDA模块中&#xff0c;矩阵元素求和类函数主要用于计算矩阵元素的总和、绝对值之和以及平方和。这些操作对于图像处理中的特征提取、…

给视频加一个动画。

为什么要给视频加一个动画&#xff1f; 很完整的视频也就是从短动画开始的。遮盖住LOG用。 C:\Users\Sam\Desktop\desktop\startup\workpython\ocr Lottie.py import subprocessdef run_ffmpeg(cmd):print("Running:", " ".join(cmd))subprocess.run(cm…

15:00开始面试,15:06就出来了,问的问题有点变态。。。

从小厂出来&#xff0c;没想到在另一家公司又寄了。 到这家公司开始上班&#xff0c;加班是每天必不可少的&#xff0c;看在钱给的比较多的份上&#xff0c;就不太计较了。没想到4月一纸通知&#xff0c;所有人不准加班&#xff0c;加班费不仅没有了&#xff0c;薪资还要降40%…

使用命令行拉取 Git 仓库

1. 克隆远程仓库&#xff08;首次获取&#xff09; # 克隆仓库到当前目录&#xff08;默认使用 HTTPS 协议&#xff09; git clone https://github.com/用户名/仓库名.git# 克隆仓库到指定目录 git clone https://github.com/用户名/仓库名.git 自定义目录名# 使用 SSH 协议克隆…

如何禁止chrome自动更新

百度了一下 下面这个方法实测有效 目录 1、WINR 输入 services.msc 2、在Services弹窗中找到下面两个service并disable 3、验证是否禁止更新成功&#xff1a; 1、WINR 输入 services.msc 2、在Services弹窗中找到下面两个service并disable GoogleUpdater InternalService…

数据库事务以及JDBC实现事务

一、数据库事务 数据库事务&#xff08;Database Transaction&#xff09;是数据库管理系统中的一个核心概念&#xff0c;它代表一组操作的集合&#xff0c;这些操作要么全部执行成功&#xff0c;要么全部不执行&#xff0c;即操作数据的最小执行单元&#xff0c;保证数据库的…