spring data jpa配置没问题,但是不会生成数据库表
程序员文章站
2022-04-13 14:09:38
...
一开始检查配置
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.hbm2ddl.auto=update
注解
@Data
@Entity
@Table(name = "comment_reply")
public class CommentsReply implements Serializable{
//父评论的主键id
@Id
private String id;
后来一步步筛查,主程序加上了注解@EnableAutoConfiguration
@EntityScan("com.tl666.comments.pojo")
@EnableAutoConfiguration
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
public class CommentsApplication {
public static void main(String[] args) {
SpringApplication.run(CommentsApplication.class, args);
}
}
加上注解后控制台报了错误,
Could not determine type for: java.util.List, at table: comments_root, for columns: [org.hibernate.mapping.Column(list_comments_reply)]
检查了下,最后网上查了下,给一个实体属性加了个@OneToMany注解就好了
@OneToMany
private List<CommentsReply> listCommentsReply;