How can solve JSON column in H2

前端 未结 10 1898
隐瞒了意图╮
隐瞒了意图╮ 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 13:57

    A workaround is actually to create a custom column data type in H2 for the jsonb type, and put the query in the datasource url like this:

    spring.datasource.url=jdbc:h2:mem:testdb;INIT=create domain if not exists jsonb as text;MODE=PostgreSQL"
    

    Now for tests and integration tests in particular, it would be preferable to use the same DB than your application, via TestContainers

提交回复
热议问题