【发布时间】:2021-12-07 17:19:24
【问题描述】:
我有一个这样的实体:
@Entity
@Data
public class Cat {
@Id
private String catId;
private String catName;
private List<String> favFoods;
}
当我启动我的 Spring boot 时,它显示了这个错误:
Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: java.util.List
在启动应用程序之前,我在 DB 中删除了表 Cat 我的 yml 设置是:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/localtest
username: catuser
password:
jpa:
show-sql: false
hibernate:
ddl-auto: create
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: true
如果我注释掉 List 字段,一切正常。 是否需要添加任何注释来解决此问题?
谢谢
【问题讨论】:
标签: java spring postgresql spring-boot jpa