1、创建接口PersonDao
public interface PersonDao {
void test();
}
2、创建接口实现类PersonRepsotoryImpl
public class PersonRepsotoryImpl implements PersonDao {
@PersistenceContext
private EntityManager entityManager;
@Override
public void test() {
Person person = entityManager.find(Person.class, 3);
System.out.println("-->" + person);
}
}
3、修改PersonRepsotory去继承PersonDao接口
public interface PersonRepsotory extends JpaRepository<Person, Integer>, JpaSpecificationExecutor<Person>,PersonDao {
}
测试:
@Test
public void testCustomRepositoryMethod(){
personRepsotory.test();
}