接口io.javabrains.repository.DepartmentRepository出现问题
我试图为大学构建CRM。但当我试图在hibernate中自动构建表时,它显示以下错误: 非托管类型接口io.javabrains.repository.DepartmentRepository 我只是尝试将存储库注释添加到其他每个Repo类中,但没有取得任何结果 系类接口io.javabrains.repository.DepartmentRepository出现问题,java,hibernate,spring-boot,Java,Hibernate,Spring Boot,我试图为大学构建CRM。但当我试图在hibernate中自动构建表时,它显示以下错误: 非托管类型接口io.javabrains.repository.DepartmentRepository 我只是尝试将存储库注释添加到其他每个Repo类中,但没有取得任何结果 系类 package io.javabrains.Entities; import java.util.Set; import javax.persistence.CascadeType; import javax.persiste
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;
}
包io.javabrains.Entities;
导入java.util.Set;
导入javax.persistence.CascadeType;
导入javax.persistence.Entity;
导入javax.persistence.GeneratedValue;
导入javax.persistence.GenerationType;
导入javax.persistence.Id;
导入javax.persistence.OneToMany;
导入javax.persistence.Table;
导入龙目数据;
导入lombok.EqualsAndHashCode;
@资料
@EqualsAndHashCode(exclude=“Student”)
@实体
@表(name=“department”)
公共课部门类别{
@身份证
@GeneratedValue(策略=GenerationType.IDENTITY)
私有int-id;
公共int getId(){
返回id;
}
公共部门类别(int-id、字符串名称、Set-students){
超级();
this.id=id;
this.name=名称;
这个。学生=学生;
}
公共无效集合id(内部id){
this.id=id;
}
公共字符串getName(){
返回名称;
}
公共void集合名(字符串名){
this.name=名称;
}
公共集getStudents(){
留学生;
}
公立学校学生(集合学生){
这个。学生=学生;
}
私有字符串名称;
@OneToMany(mappedBy=“departmentCategory”,cascade=CascadeType.ALL)
私人学生;
}
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);
}
}
包io.javabrains.repository;
导入org.springframework.data.jpa.repository.JpaRepository;
导入org.springframework.stereotype.Repository;
@存储库
公共接口DepartmentRepository扩展了JpaRepository{
}
CRMSChoolapplicton.class
包io.javabrains;
导入org.springframework.boot.SpringApplication;
导入org.springframework.boot.autoconfigure.springboot应用程序;
导入org.springframework.web.bind.annotation.GetMapping;
@SpringBoot应用程序
公共类CrmSchoolApplication{
公共静态void main(字符串[]args){
运行(CrmSchoolApplication.class,args);
}
}
尝试更改您的J假设:
public interface DepartmentRepository extends JpaRepository<Department, Integer>
public interface DepartmentRepository扩展了JpaRepository
而不是
public interface DepartmentRepository extends JpaRepository<DepartmentRepository, Integer>
public interface DepartmentRepository扩展了JpaRepository
尝试更改您的JPA存储:
public interface DepartmentRepository extends JpaRepository<Department, Integer>
public interface DepartmentRepository扩展了JpaRepository
而不是
public interface DepartmentRepository extends JpaRepository<DepartmentRepository, Integer>
public interface DepartmentRepository扩展了JpaRepository