How can solve JSON column in H2

前端 未结 10 1886
隐瞒了意图╮
隐瞒了意图╮ 2020-12-24 13:39

I use in application MySQL 5.7 and I have JSON columns. When I try running my integration tests don\'t work because the H2 database can\'t create the table. This is the erro

10条回答
  •  一整个雨季
    2020-12-24 14:02

    This is how I solved it in Spring context:

    1. Create /src/test/resources/init.sql
    CREATE TYPE "JSONB" AS json;
    
    1. Configure H2 datasource as follows /src/test/resources/application-test.yml
    spring:
      datasource:
        driver-class-name: org.h2.Driver
        url: jdbc:h2:mem:db;DB_CLOSE_DELAY=-1;INIT=RUNSCRIPT FROM 'classpath:init.sql'
        username: sa
        password: sa
    

    Source article

提交回复
热议问题