spring data jpa配置没问题,但是不会生成数据库表

本文介绍了在Spring Boot应用中遇到的实体类属性无法自动映射到数据库的问题,通过添加@EnableAutoConfiguration、@EntityScan注解以及在实体类中使用@OneToMany注解解决了集合类型属性的映射错误,避免了控制台出现'Could not determine type for: java.util.List...'的警告。
摘要由CSDN通过智能技术生成

一开始检查配置

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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值