feat: 切换数据库从H2到MySQL
- 安装MySQL数据库 - 创建xuan_deduct数据库和xuan_user用户 - 创建deduct_record表 - 修改application.properties配置MySQL连接 - 测试验证数据库连接和数据保存功能
This commit is contained in:
1 parent
91a14ca6d1
commit
097173426f
3 files changed
+13
-19
No files matched your search
Binary file not shown.
@@ -117,6 +117,13 @@
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
<!-- MySQL Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
|
||||
<!-- H2 Database (for development) -->
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
|
||||
@@ -1,30 +1,17 @@
|
||||
server.port=8080
|
||||
spring.application.name=xuan-utils-pro
|
||||
|
||||
# H2 Database Configuration (Development)
|
||||
spring.datasource.url=jdbc:h2:file:./data/xuan;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=
|
||||
# MySQL Database Configuration
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/xuan_deduct?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true
|
||||
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.username=xuan_user
|
||||
spring.datasource.password=xuan_password
|
||||
|
||||
# JPA Configuration
|
||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.properties.hibernate.format_sql=true
|
||||
|
||||
# H2 Console (Development only)
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.path=/h2-console
|
||||
|
||||
# MySQL Configuration (Production - uncomment when needed)
|
||||
#spring.datasource.url=jdbc:mysql://localhost:3306/xuan_deduct?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf8
|
||||
#spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
|
||||
#spring.datasource.username=root
|
||||
#spring.datasource.password=your_password
|
||||
#spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
|
||||
#spring.jpa.hibernate.ddl-auto=update
|
||||
|
||||
# Logging
|
||||
logging.level.xuan=DEBUG
|
||||
logging.level.org.hibernate.SQL=DEBUG
|
||||
Reference in new issue
Block a user