org.springframework.beans.factory.BeanCreationException: 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 org.hibernate.AnnotationException: @Temporal should only be set on a java.util.Date or java.util.Calendar property: com.flx.phlxtimescaledb.entity.SourceTimeTagPK.sourceTime
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1708) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
解决:
@Temporal :向数据库映射日期(Date)属性时用来调整映射的精度。
我这里不需要,我的数据库表是timestamp 类型的
所以:
换成column 的可以了
@Column :类中属性名和表中对应字段名不相同时,会使用该注解,指明在类中对应的字段 * * @Column(name="对应的表中字段名") * * nullable 属性用来指明是否可以为空,false 为不能为空