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