V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
shadowfish0
V2EX  ›  问与答

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

  •  
  •   shadowfish0 · Aug 16, 2021 · 955 views
    This topic created in 1727 days ago, the information mentioned may be changed or developed.

    原来项目是单数据源的,用 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")也依然无效,现在实在是没有办法了...

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   939 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 19:47 · PVG 03:47 · LAX 12:47 · JFK 15:47
    ♥ Do have faith in what you're doing.