commit 433f28f8f0b49df4fc866abbc51b62b22e1a0055 Author: JACKYMYPERSON Date: Mon Mar 2 11:47:03 2026 +0800 初始化项目 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6cb8e97 --- /dev/null +++ b/.gitignore @@ -0,0 +1,121 @@ +# ===================== 通用基础忽略 ===================== +# 操作系统相关文件 +.DS_Store # macOS 系统文件 +Thumbs.db # Windows 系统文件 +desktop.ini # Windows 配置文件 +*.tmp # 临时文件 +*.temp # 临时文件 +*.swp # Vim 交换文件 +*~ # 临时文件 + +# 日志文件 +logs/ +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# 缓存和构建产物 +.cache/ +dist/ +build/ +out/ +target/ # Java 编译产物 +classes/ # Java 类文件 +*.o # 编译中间文件 +*.obj # 编译中间文件 + +# ===================== 编程语言专属忽略 ===================== +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +env/ +venv/ +ENV/ +*.egg-info/ +.eggs/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg + +# Node.js +node_modules/ +npm-debug.log +yarn.lock +package-lock.json +pnpm-lock.yaml +yarn-error.log +.nyc_output/ +coverage/ + +# Java +*.class +*.jar +*.war +*.ear +*.jmod +*.bak +*.tmp +hs_err_pid* +replay_pid* + +# ===================== IDE/编辑器配置 ===================== +# VS Code +.vscode/ +*.code-workspace +.history/ + +# IntelliJ IDEA / WebStorm +.idea/ +*.iml +*.iws +*.ipr +out/ + +# Eclipse +.classpath +.project +.settings/ +bin/ +.metadata/ + +# ===================== 其他常见忽略 ===================== +# 环境变量文件 +.env +.env.local +.env.development.local +.env.test.local +.env.production.local +.env.*.local + +# 压缩包 +*.zip +*.rar +*.7z +*.tar.gz + +# 数据库文件 +*.db +*.sqlite +*.sqlite3 +data/ + +# 敏感信息文件 +*.pem +*.key +*.secret +credentials.json \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..40e3b34 --- /dev/null +++ b/pom.xml @@ -0,0 +1,41 @@ + + 4.0.0 + + cn.mayiming + javamemories + 1.0-SNAPSHOT + jar + + javamemories + http://maven.apache.org + + + org.springframework.boot + spring-boot-starter-parent + + 3.2.3 + + + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-redis + + + diff --git a/src/main/java/cn/mayiming/App.java b/src/main/java/cn/mayiming/App.java new file mode 100644 index 0000000..72f4bda --- /dev/null +++ b/src/main/java/cn/mayiming/App.java @@ -0,0 +1,14 @@ +package cn.mayiming; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class App +{ + + public static void main( String[] args ) + { + SpringApplication.run(App.class, args); + } +} diff --git a/src/main/java/cn/mayiming/Controller/Redis/RedisParam.java b/src/main/java/cn/mayiming/Controller/Redis/RedisParam.java new file mode 100644 index 0000000..59e7ed9 --- /dev/null +++ b/src/main/java/cn/mayiming/Controller/Redis/RedisParam.java @@ -0,0 +1,26 @@ +package cn.mayiming.Controller.Redis; + +public class RedisParam { + private String key; + private String value; + + // 必须加无参构造器(JSON解析需要) + public RedisParam() {} + + // GET/SET方法(必须加,否则JSON解析不到值) + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/main/java/cn/mayiming/Controller/Redis/Redistest.java b/src/main/java/cn/mayiming/Controller/Redis/Redistest.java new file mode 100644 index 0000000..71b1232 --- /dev/null +++ b/src/main/java/cn/mayiming/Controller/Redis/Redistest.java @@ -0,0 +1,23 @@ +package cn.mayiming.Controller.Redis; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.concurrent.TimeUnit; + + +@RestController +public class Redistest { + @Autowired + private StringRedisTemplate stringRedisTemplate; + @PostMapping("/redis/put") + public String put(@RequestBody RedisParam param) { + String key = param.getKey(); + stringRedisTemplate.opsForValue().set(key, "123", 10, TimeUnit.MINUTES); + String redisValue = stringRedisTemplate.opsForValue().get(key); + return "Redis写入成功!key=" + key + ",value=" + redisValue; + } +} diff --git a/src/main/java/cn/mayiming/Controller/User.java b/src/main/java/cn/mayiming/Controller/User.java new file mode 100644 index 0000000..9991bc9 --- /dev/null +++ b/src/main/java/cn/mayiming/Controller/User.java @@ -0,0 +1,17 @@ +package cn.mayiming.Controller; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.Map; + +@RestController +public class User { + @PostMapping("/login") + public Map login() { + Map map = new HashMap<>(); + map.put("username", "admin"); + return map; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..29d2388 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,9 @@ +server: + port: 9090 +spring: + data: + redis: + port: 6379 + password: "" + database: 0 + timeout: 10000 \ No newline at end of file diff --git a/src/test/java/cn/mayiming/AppTest.java b/src/test/java/cn/mayiming/AppTest.java new file mode 100644 index 0000000..2244532 --- /dev/null +++ b/src/test/java/cn/mayiming/AppTest.java @@ -0,0 +1,38 @@ +package cn.mayiming; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/target/classes/application.yml b/target/classes/application.yml new file mode 100644 index 0000000..29d2388 --- /dev/null +++ b/target/classes/application.yml @@ -0,0 +1,9 @@ +server: + port: 9090 +spring: + data: + redis: + port: 6379 + password: "" + database: 0 + timeout: 10000 \ No newline at end of file