我正在使用spring boot将表映射到POJO,我收到以下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/mercadolibre/linters/db/config/DbaConfig.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [linter_summary] in table [result]; found [json (Types#CHAR)], but expecting [varchar(255) (Types#VARCHAR)]
db中的字段 linter_summary
是JSON类型,而我的pojo上的字段是String . 我发生了这个错误,java中的JSON字段有一个特殊的变量吗?
1 回答
添加此Maven依赖项:
接下来,将此批注添加到实体类:
然后将其添加到列定义中:
其中
@Type
是org.hibernate.annotations.Type
有关说明,请参阅this article