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

Liquibase插入日期数据报错:缺少java.util.Date(H2数据库)

Fix: Liquibase Insert Error with H2 Date Field (Java 8)

I've run into similar compatibility issues between older Liquibase versions, Java 8, and H2 before. Here's how to resolve your error related to missing java.util.Date when inserting date values into the Aluno table:

Root Cause

Your Liquibase version (3.5.3) is quite outdated (released in 2017) and has known compatibility bugs with Java 8's date handling and newer H2 database versions. This leads to class loading issues when parsing date type fields during inserts.

Step-by-Step Fixes

1. Upgrade Liquibase to a Java 8-Compatible Version

Update your liquibase-core dependency to a stable, newer version that properly supports Java 8. Version 3.8.9 is a reliable choice here:

<dependency>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-core</artifactId>
  <version>3.8.9</version>
</dependency>

2. Pin H2 Database to a Compatible Version

Your H2 dependency doesn't specify a version, so Maven pulls the latest release by default. Newer H2 versions break compatibility with old Liquibase builds. Use a stable, compatible version like 1.4.199:

<dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
  <version>1.4.199</version>
</dependency>

You don't need to repeat the type attribute in your insert columns—Liquibase can infer the field type from your table schema. Removing these avoids potential type mismatches:

#popular Aluno - changeSet:
  id: 88801
  author: Nicholas
  changes:
    - insert:
        columns:
          - column:
              name: AluId
              value: 1
          - column:
              name: AluNome
              value: Mariana Celegati
          - column:
              name: AluEnd
              value: Rua Siqueira Bueno, 90
          - column:
              name: AluCPF
              value: 44455522211
          - column:
              name: AluBairro
              value: Mooca
          - column:
              name: AluCel
              value: 55552222
          - column:
              name: AluTel
              value: 966662222
          - column:
              name: AluDataEnt
              valueDate: 2017-02-15
          - column:
              name: AluDataVenc
              valueDate: 2018-02-15
        tableName: Aluno

Final Steps

After updating your dependencies and script, run mvn clean install to refresh your project's libraries, then re-execute your Liquibase migrations. This should resolve the java.util.Date missing error and successfully insert your date values into the H2 database.

内容的提问来源于stack exchange,提问作者Nicholas Maestrello Agiz

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 06:43:47