初始化项目

This commit is contained in:
JACKYMYPERSON
2026-03-02 11:47:03 +08:00
commit 433f28f8f0
9 changed files with 298 additions and 0 deletions

121
.gitignore vendored Normal file
View File

@@ -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

41
pom.xml Normal file
View File

@@ -0,0 +1,41 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.mayiming</groupId>
<artifactId>javamemories</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>javamemories</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- Spring Boot 3最新稳定版可在官网确认最新版本 -->
<version>3.2.3</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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<String, String> login() {
Map<String, String> map = new HashMap<>();
map.put("username", "admin");
return map;
}
}

View File

@@ -0,0 +1,9 @@
server:
port: 9090
spring:
data:
redis:
port: 6379
password: ""
database: 0
timeout: 10000

View File

@@ -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 );
}
}

View File

@@ -0,0 +1,9 @@
server:
port: 9090
spring:
data:
redis:
port: 6379
password: ""
database: 0
timeout: 10000