You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JHipster 7.9.3项目MySQL测试容器时区测试失败求助

JHipster项目MySQL时区测试失败问题

我通过命令行创建了一个简单的JHipster项目,执行命令:

jhipster

选择开发环境数据库为MySQL,该项目使用testcontainers运行集成测试。我未添加自定义实体,但运行./mvnw clean verify时,HibernateTimeZoneIT测试抛出以下错误:

[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   HibernateTimeZoneIT.storeInstantWithZoneIdConfigShouldBeStoredOnGMTTimeZone:66->assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone:159
expected: "2014-11-12 05:50:00.0"
 but was: "2014-11-12 06:50:00.0"
[ERROR]   HibernateTimeZoneIT.storeLocalDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone:78->assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone:159
expected: "2014-11-12 06:50:00.0"
 but was: "2014-11-12 07:50:00.0"
[ERROR]   HibernateTimeZoneIT.storeOffsetDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone:90->assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone:159
expected: "2011-12-14 08:30:00.0"
 but was: "2011-12-14 09:30:00.0"
[ERROR]   HibernateTimeZoneIT.storeZoneDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone:102->assertThatDateStoredValueIsEqualToInsertDateValueOnGMTTimeZone:159
expected: "2011-12-14 08:30:00.0"
 but was: "2011-12-14 09:30:00.0"
[INFO]
[ERROR] Tests run: 90, Failures: 4, Errors: 0, Skipped: 0

项目创建配置

Welcome to JHipster v7.9.3

Application files will be generated in folder: C:\Users\Midhu Moyalan\Workspaces\JHipsterWorkspace\sampleProject
 _______________________________________________________________________________________________________________

  应用创建文档可参考官方指引
  若觉得JHipster有用,可考虑为项目提供支持
 _______________________________________________________________________________________________________________

? Which *type* of application would you like to create? Monolithic application (recommended for simple projects)
? What is the base name of your application? sampleProject
? Do you want to make it reactive with Spring WebFlux? No
? What is your default Java package name? com.mycompany.myapp
? Which *type* of authentication would you like to use? JWT authentication (stateless, with a token)
? Which *type* of database would you like to use? SQL (H2, PostgreSQL, MySQL, MariaDB, Oracle, MSSQL)
? Which *production* database would you like to use? MySQL
? Which *development* database would you like to use? MySQL
? Which cache do you want to use? (Spring cache abstraction) Ehcache (local cache, for a single node)
? Do you want to use Hibernate 2nd level cache? Yes
? Would you like to use Maven or Gradle for building the backend? Maven
? Do you want to use the JHipster Registry to configure, monitor and scale your application? No
? Which other technologies would you like to use?
? Which *Framework* would you like to use for the client? Angular
? Do you want to generate the admin UI? Yes
? Would you like to use a Bootswatch theme? Default JHipster
? Would you like to enable internationalization support? No
? Please choose the native language of the application English
? Besides JUnit and Jest, which testing frameworks would you like to use?
? Would you like to install other generators from the JHipster Marketplace? No
Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 99,999 days
        for: CN=Java Hipster, OU=Development, O=com.mycompany.myapp, L=, ST=, C=

环境信息

  • Java版本:
$ java --version
java 17.0.2 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)
  • 本地Docker已下载mysql:8.0.30镜像

已尝试的无效方案

  • 在my.cnf文件中添加default-time-zone = "UTC";
  • 创建init.sql文件写入SET time_zone = 'UTC';,并通过.withInitScript配置到MySQL容器;
  • 为容器添加环境变量.withEnv("TZ","UTC")或.withEnv("serverTimezone","UTC")。

我希望继续使用testcontainers,请问使用MySQL作为开发数据库时是否需要额外配置?


内容的提问来源于stack exchange,提问作者MiMoy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 17:32:50