首页 > 解决方案 > Spring Boot 尝试创建从项目中删除的类

问题描述

我删除了其中一个Components项目:

    @Component
    public interface ClientRepo extends CrudRepository<Client, Integer> {
    }

我已将Client课程从更改EntityEmbeddable

    @Getter
    @Setter
    @Embeddable
    public class Client {
      @NotNull
      @Size(max = 200)
      private String email;
      @NotNull
      @Size(max = 200)
      private String phoneNumber;
   }

在这里我使用这个Client类:

@Entity
@Table(name = "MEETINGS")
public class Meeting extends BaseEntity {

  @Embedded
  private Client client;
}

*这是我尝试启动项目时得到的结果:**

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: The given domain class does not contain an id attribute!

标签: springspring-bootjpaintellij-idearepository

解决方案


根据我的评论添加答案:当您从项目中删除或重命名一个类时,请务必清理您的构建目录以摆脱其已编译的 .class 等效项。如果您使用的是 maven,则可以通过调用clean命令或手动删除目标目录来完成。


推荐阅读