feat: Initialize Spring Boot project with user authentication

- Add Maven Wrapper for easier project setup
- Create pom.xml with Spring Boot dependencies for web, data JPA, and security
- Implement main application class RestUserAuthApplication
- Configure security settings with SecurityConfig class
- Create AuthController for user authentication and registration
- Implement UserController to retrieve current user information
- Define DTOs for authentication requests and responses
- Create User and Role models for user management
- Implement UserRepository for database interactions
- Add JWT authentication filter and token provider for secure API access
- Create CustomUserDetailsService for loading user-specific data
- Configure application properties for database and JWT settings
- Add basic test class for application context loading
- Include HTTP request examples for user registration and login in tests
This commit is contained in:
2025-06-06 07:37:01 +00:00
commit 083d9efe9a
22 changed files with 1109 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
spring.application.name=rest-user-auth
# ===============================
# DATABASE CONFIGURATION
# ===============================
# 数据库 URL请替换 your_database_name 为你的数据库名
spring.datasource.url=jdbc:mysql://10.254.100.62:3306/play-auth
# 数据库用户名
spring.datasource.username=enoch
# 数据库密码
spring.datasource.password=enoch@123
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# ===============================
# JPA / HIBERNATE CONFIGURATION
# ===============================
# 自动更新数据库表结构。在开发时方便,生产环境建议使用 Flyway 或 Liquibase
spring.jpa.hibernate.ddl-auto=update
# 在控制台显示执行的 SQL 语句,便于调试
spring.jpa.show-sql=true
# 格式化显示的 SQL
spring.jpa.properties.hibernate.format_sql=true
# ===============================
# JWT CONFIGURATION
# ===============================
# 用于签发 JWT 的密钥。请务必修改为一个足够长且复杂的字符串,不要在生产环境中泄露
app.jwt.secret=YourSuperSecretKeyForJWTsWhichIsLongAndSecureAbcdAbcdAbcdAbcdAbcdAbcdAbcdAbcdAbcdAbcd
# JWT 的过期时间(毫秒),这里设置为 1 小时
app.jwt.expiration-ms=3600000