为了账号安全,请及时绑定邮箱和手机立即绑定

Spring Boot JPA @Entity 未定义为 bean

Spring Boot JPA @Entity 未定义为 bean

慕村9548890 2021-10-13 16:00:26
我无法运行我的 Spring Boot 应用程序,因为 JPA 存在问题。但我无法找到问题并解决它。我搜索了几个堆栈溢出主题的解决方案,但没有一个解决方案对我有帮助。我定义了以下模型:package xyz.blackmonster.window.models;import java.util.List;import javax.persistence.CascadeType;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.FetchType;import javax.persistence.GeneratedValue;import javax.persistence.Id;import javax.persistence.OneToMany;import javax.persistence.OneToOne;import org.hibernate.annotations.GenericGenerator;/** * Window order */@Entitypublic class Order {    @Id    @GeneratedValue(generator = "system-uuid")    @GenericGenerator(name = "system-uuid", strategy = "uuid2")    private String uuid;    @OneToMany(fetch = FetchType.EAGER, mappedBy = "order", cascade = CascadeType.ALL)    private List<Window> windows;    @OneToOne(fetch = FetchType.EAGER, mappedBy = "order", cascade = CascadeType.ALL)    private Service service;    @OneToOne(fetch = FetchType.EAGER, mappedBy = "order", cascade = CascadeType.ALL)    private Cost cost;    @Column(name = "email")    private String email;    public String getUuid() {        return uuid;    }    public void setUuid(String uuid) {        this.uuid = uuid;    }    public List<Window> getWindows() {        return windows;    }    public void setWindows(List<Window> windows) {        this.windows = windows;    }    public Service getService() {        return service;    }    public void setService(Service service) {        this.service = service;    }    public Cost getCost() {        return cost;    }    public void setCost(Cost cost) {        this.cost = cost;    }    public String getEmail() {        return email;    }    public void setEmail(String email) {        this.email = email;    }}如您所见,实体使用了正确的导入 (javax.persistence.Entity)。我指出这一点,因为这是我遇到的解决方案之一。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 163 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信