diff --git a/2026-07-01/backend/GradeSystem/src/com/yngang/demo/Main.java b/2026-07-01/backend/GradeSystem/src/com/yngang/demo/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..8ea5d35ec8cfbebb1918338509f151534a464525
--- /dev/null
+++ b/2026-07-01/backend/GradeSystem/src/com/yngang/demo/Main.java
@@ -0,0 +1,56 @@
+package com.yngang.demo;
+
+// 需要对入库操作正确加锁,不加锁会导致库存不一致,
+// 要是两个线程同时执行到这行代码,都先加了5件,最后库存为10件会多出来5件库存导致库存不一致问题
+public class Main {
+
+ static class Warehouse {
+ private int stock;
+ public Warehouse(int stock) {
+ this.stock = stock;
+ }
+ public int getStock() {
+ return stock;
+ }
+ public void setStock(int stock) {
+ this.stock = stock;
+ }
+ }
+
+ static class MoveTask implements Runnable {
+ private Warehouse warehouse;
+ private String name;
+ private int moveCount;
+ public MoveTask(Warehouse warehouse, String name, int moveCount) {
+ this.warehouse = warehouse;
+ this.name = name;
+ this.moveCount = moveCount;
+ }
+ @Override
+ public void run() {
+ for (int i = 0; i < moveCount; i++) {
+ synchronized (warehouse) {
+ warehouse.setStock(warehouse.getStock() + 5);
+ }
+ System.out.println(name + " 入库 5 件,当前库存 " + warehouse.getStock());
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ Warehouse warehouse = new Warehouse(0);
+ MoveTask moveTaskA = new MoveTask(warehouse, "搬运工A", 10);
+ MoveTask moveTaskB = new MoveTask(warehouse, "搬运工B", 10);
+ Thread threadA = new Thread(moveTaskA);
+ Thread threadB = new Thread(moveTaskB);
+ threadA.start();
+ threadB.start();
+ try {
+ threadA.join();
+ threadB.join();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.printf("最终库存:%d 件,是否为100件:%b", warehouse.getStock(), (warehouse.getStock() == 100));
+ }
+}
diff --git a/2026-07-03/spring-demo/pom.xml b/2026-07-03/spring-demo/pom.xml
index 3149978dc75824ab90b251472cceeaff3f9ed692..5036a53468df1a167c9c9531ff7d7878949b7c76 100644
--- a/2026-07-03/spring-demo/pom.xml
+++ b/2026-07-03/spring-demo/pom.xml
@@ -42,6 +42,14 @@
org.springframework.boot
spring-boot-starter-validation
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ org.apache.commons
+ commons-pool2
+
org.projectlombok
lombok
diff --git a/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/config/RedisConfig.java b/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/config/RedisConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..9fdf27ace997817f2a23c6977bb73cbde192f8ad
--- /dev/null
+++ b/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/config/RedisConfig.java
@@ -0,0 +1,29 @@
+package com.yngang.springdemo.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@Configuration
+public class RedisConfig {
+
+ @Bean
+ public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
+ RedisTemplate redisTemplate = new RedisTemplate<>();
+ redisTemplate.setConnectionFactory(redisConnectionFactory);
+
+ // 设置序列化器
+ redisTemplate.setKeySerializer(new StringRedisSerializer());
+ redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
+ redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+ redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
+
+ redisTemplate.afterPropertiesSet();
+
+ return redisTemplate;
+ }
+
+}
diff --git a/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/exception/BusinessException.java b/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/exception/BusinessException.java
index 0c78ea045418705dcb1d0ed145ee9d184921d5c0..ec71c0de9f244a0bbbf25eb54914b272697b7a72 100644
--- a/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/exception/BusinessException.java
+++ b/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/exception/BusinessException.java
@@ -6,7 +6,7 @@ import lombok.Getter;
* 自定义业务异常:抛出此异常时,全局异常处理器会自动捕获并返回友好的错误信息
*/
@Getter
-public class BusinessException extends Exception {
+public class BusinessException extends RuntimeException {
private static final int DEFAULT_CODE = 500;
diff --git a/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/service/RedisDemoService.java b/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/service/RedisDemoService.java
new file mode 100644
index 0000000000000000000000000000000000000000..620e051b5807bd31c9dd257d2fbd194d536581fe
--- /dev/null
+++ b/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/service/RedisDemoService.java
@@ -0,0 +1,6 @@
+package com.yngang.springdemo.service;
+
+public interface RedisDemoService {
+
+ void demo();
+}
diff --git a/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/service/impl/RedisDemoServiceImpl.java b/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/service/impl/RedisDemoServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..ecff477d86d579320f2122cd232fb8465a6d17a5
--- /dev/null
+++ b/2026-07-03/spring-demo/src/main/java/com/yngang/springdemo/service/impl/RedisDemoServiceImpl.java
@@ -0,0 +1,50 @@
+package com.yngang.springdemo.service.impl;
+
+import com.yngang.springdemo.service.RedisDemoService;
+import com.yngang.springdemo.util.RedisUtil;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Set;
+
+@Service
+@RequiredArgsConstructor
+public class RedisDemoServiceImpl implements RedisDemoService {
+
+ private final RedisUtil redisUtil;
+
+ @Override
+ public void demo() {
+ redisUtil.set("name", "zhangsan");
+ redisUtil.set("age", 18);
+ Object name = redisUtil.get("name");
+ Object age = redisUtil.get("age");
+ System.out.println(name);
+ System.out.println(age);
+
+ redisUtil.hSet("user:1", "name", "zhangsan");
+ redisUtil.hSet("user:1", "age", 18);
+ Object userName = redisUtil.hGet("user:1", "name");
+ System.out.println(userName);
+ Object userAge = redisUtil.hGet("user:1", "age");
+ System.out.println(userAge);
+
+ redisUtil.rPush("mylist", "zhangsan");
+ redisUtil.rPush("mylist", "lisi");
+ List