我试图为大学建立CRM。但是,当我试图在休眠状态下自动建立表时,它向我显示以下错误: 非托管类型接口io.javabrains.repository.DepartmentRepository
我只是尝试将存储库批注添加到其他所有Repo类中,但未实现任何结果
部门Category.class
package io.javabrains.Entities;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(exclude="Student")
@Entity
@Table(name="department")
public class DepartmentCategory {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
public int getId() {
return id;
}
public DepartmentCategory(int id, String name, Set<Student> students) {
super();
this.id = id;
this.name = name;
this.students = students;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Student> getStudents() {
return students;
}
public void setStudents(Set<Student> students) {
this.students = students;
}
private String name;
@OneToMany(mappedBy = "departmentCategory",cascade = CascadeType.ALL)
private Set<Student>students;
}
DepartmentRepository.class
package io.javabrains.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface DepartmentRepository extends JpaRepository<DepartmentRepository, Integer> {
}
CrmSchoolApplicaton.class
package io.javabrains;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
@SpringBootApplication
public class CrmSchoolApplication {
public static void main(String[] args) {
SpringApplication.run(CrmSchoolApplication.class, args);
}
}
......
答案 0 :(得分:2)
尝试更改您的JpaRepository:
public interface DepartmentRepository extends JpaRepository<Department, Integer>
代替
public interface DepartmentRepository extends JpaRepository<DepartmentRepository, Integer>