fix: 测试使用远程 MySQL,取消跳过

- 测试 application.yml 改为连接远程 pguser-db
- 移除 surefire skipTests,移除 H2 依赖,增加 mysql-connector-j(test)
This commit is contained in:
神码-方晓辉 2026-02-02 07:52:00 +08:00
parent e57dd9df2f
commit 91676531b8
2 changed files with 10 additions and 22 deletions

View File

@ -37,24 +37,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- H2 内存数据库,供单模块测试使用 -->
<!-- MySQL 驱动,测试连接远程库 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- 集成测试依赖 MySQL 表结构,单模块无 DB 时跳过;完整测试请从 pangu-admin 启动并连接 MySQL 后执行 -->
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,10 +1,10 @@
# 测试环境配置,供 pangu-system 单模块测试使用
# 测试环境配置,使用与 pangu-admin 相同的远程 MySQL
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:testdb;MODE=MySQL;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS PUBLIC
username: sa
password:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://8.148.25.55:3306/pguser-db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: aly2024A
mybatis-plus:
mapper-locations: classpath*:mapper/**/*.xml
@ -13,6 +13,7 @@ mybatis-plus:
map-underscore-to-camel-case: true
pagehelper:
helper-dialect: h2
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countSql