V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
shadowfish0
V2EX  ›  问与答

spring 多数据源下如何初始化 H2 数据库?

  •  
  •   shadowfish0 · 2021-08-16 14:52:06 +08:00 · 463 次点击
    这是一个创建于 955 天前的主题,其中的信息可能已经有所发展或是发生改变。

    原来项目是单数据源的,用 H2 内存数据库做测试用,可以直接用 spring 提供的 schema 、data 配置来自动初始化,但是用了多数据源之后这两个参数的解析一直有问题,遂弃用,转而想要实现每个测试 BeforeAll 时执行初始化 SQL,但是又一直报 server time zone 异常: org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specific time zone value if you want to utilize time zone support. 然后上网查询到 H2 不支持设置 serverTimezone,我尝试 System.setProperty("user.timezone", "GMT")也依然无效,现在实在是没有办法了...

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3207 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:59 · PVG 19:59 · LAX 04:59 · JFK 07:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.