mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
feat(config): improve MariaDB compatibility & env configuration
功能更新(配置):优化 MariaDB 兼容性与环境变量配置支持 - Changed collation from `utf8mb4_0900_ai_ci` to `utf8mb4_unicode_ci` for MariaDB compatibility. 为兼容 MariaDB,将字符集排序规则从 `utf8mb4_0900_ai_ci` 修改为 `utf8mb4_unicode_ci`。 - Updated `application-dev.yml` to support variable loading from root `.env` file or system environment variables. 修改 `application-dev.yml`,支持从根目录下的 `.env` 文件或系统环境变量中读取配置。 - Added `.env.template` as a reference for required configuration variables. 新增 `.env.template` 文件,提供配置变量示例。
This commit is contained in:
parent
8318ba5e55
commit
8748201012
5 changed files with 43 additions and 12 deletions
9
main/manager-api/.env.template
Normal file
9
main/manager-api/.env.template
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
KNIFE4J_USERNAME = renren
|
||||
KNIFE4J_PASSWORD = 2ZABCDEUgF
|
||||
DB_DRIVER=org.mariadb.jdbc.Driver
|
||||
DB_URL = jdbc:mysql://127.0.0.1:3306/xiaozhi_esp32_server?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
DB_USERNAME = root
|
||||
DB_PASSWORD = 123456
|
||||
REDIS_HOST = 127.0.0.1
|
||||
REDIS_PASSWORD =
|
||||
REDIS_DATABASE=0
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
<shiro.version>2.0.2</shiro.version>
|
||||
<captcha.version>1.6.2</captcha.version>
|
||||
<guava.version>33.0.0-jre</guava.version>
|
||||
<liquibase-core.version>4.20.0</liquibase-core.version>
|
||||
<liquibase-core.version>4.31.1</liquibase-core.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
@ -157,6 +157,10 @@
|
|||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||
|
|
@ -197,6 +201,11 @@
|
|||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.cdimascio</groupId>
|
||||
<artifactId>dotenv-java</artifactId>
|
||||
<version>3.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- 阿里云maven仓库 -->
|
||||
|
|
|
|||
|
|
@ -2,11 +2,24 @@ package xiaozhi;
|
|||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import io.github.cdimascio.dotenv.Dotenv;
|
||||
|
||||
@SpringBootApplication
|
||||
public class AdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Dotenv dotenv = Dotenv.load();
|
||||
System.setProperty("DB_USERNAME", dotenv.get("DB_USERNAME", "root"));
|
||||
System.setProperty("DB_PASSWORD", dotenv.get("DB_PASSWORD", "123456"));
|
||||
System.setProperty("DB_DRIVER", dotenv.get("DB_DRIVER", "com.mysql.cj.jdbc.Driver"));
|
||||
System.setProperty("DB_URL", dotenv.get("DB_URL", "jdbc:mariadb://127.0.0.1:3306/xiaozhi_esp32_server?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true"));
|
||||
System.setProperty("REDIS_HOST", dotenv.get("REDIS_HOST", "127.0.0.1"));
|
||||
System.setProperty("REDIS_PASSWORD", dotenv.get("REDIS_PASSWORD", ""));
|
||||
System.setProperty("REDIS_PORT", dotenv.get("REDIS_PORT", "6379"));
|
||||
System.setProperty("REDIS_DATABASE", dotenv.get("REDIS_DATABASE", ""));
|
||||
System.setProperty("KNIFE4J_USERNAME", dotenv.get("KNIFE4J_USERNAME", "renren"));
|
||||
System.setProperty("KNIFE4J_PASSWORD", dotenv.get("KNIFE4J_PASSWORD", "2ZABCDEUgF"));
|
||||
|
||||
SpringApplication.run(AdminApplication.class, args);
|
||||
System.out.println("http://localhost:8002/xiaozhi/doc.html");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@ knife4j:
|
|||
enable: true
|
||||
basic:
|
||||
enable: false
|
||||
username: renren
|
||||
password: 2ZABCDEUgF
|
||||
username: ${KNIFE4J_USERNAME}
|
||||
password: ${KNIFE4J_PASSWORD}
|
||||
setting:
|
||||
enableFooter: false
|
||||
spring:
|
||||
datasource:
|
||||
druid:
|
||||
#MySQL
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/xiaozhi_esp32_server?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: 123456
|
||||
driver-class-name: ${DB_DRIVER}
|
||||
url: ${DB_URL}
|
||||
username: ${DB_USERNAME}
|
||||
password: ${DB_PASSWORD}
|
||||
initial-size: 10
|
||||
max-active: 100
|
||||
min-idle: 10
|
||||
|
|
@ -38,10 +38,10 @@ spring:
|
|||
multi-statement-allow: true
|
||||
data:
|
||||
redis:
|
||||
host: 127.0.0.1 # Redis服务器地址
|
||||
port: 6379 # Redis服务器连接端口
|
||||
password: # Redis服务器连接密码(默认为空)
|
||||
database: 0 # Redis数据库索引(默认为0)
|
||||
host: ${REDIS_HOST} # Redis服务器地址
|
||||
port: ${REDIS_PORT} # Redis服务器连接端口
|
||||
password: ${REDIS_PASSWORD} # Redis服务器连接密码(默认为空)
|
||||
database: ${REDIS_DATABASE} # Redis数据库索引(默认为0)
|
||||
timeout: 10000ms # 连接超时时间(毫秒)
|
||||
lettuce:
|
||||
pool:
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ CREATE TABLE `ai_ota` (
|
|||
`creator` bigint DEFAULT NULL COMMENT '创建者',
|
||||
`create_date` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='固件信息表';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='固件信息表';
|
||||
|
|
|
|||
Loading…
Reference in a new issue