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.pswp.cn/pingmian/81017.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/81017.shtml
英文地址,請注明出處:http://en.pswp.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;保證數據庫的…