【发布时间】:2019-03-08 12:48:06
【问题描述】:
我想创建自定义存储库:
public interface FriendRepositoryCustom {
Page<Friend> findFriends(FriendCriteria friendCriteria, Pageable pageable);
}
及其实现:
@Repository
@Transactional(readOnly = true)
public class FriendRepositoryCustomImpl implements FriendRepositoryCustom {
@PersistenceContext
EntityManager entityManager;
@Override
public Page<Friend> findFriends(FriendCriteria friendCriteria, Pageable pageable) {
...
}
并将其添加到主存储库:
@Repository
public interface FriendRepository extends JpaRepository<Friend, Long>, JpaSpecificationExecutor<Friend>, FriendRepositoryCustom {
}
当我启动应用程序时出现此错误:
原因: org.springframework.data.mapping.PropertyReferenceException:否 为类型 Friend 找到属性 findFriends!在 org.springframework.data.mapping.PropertyPath.(PropertyPath.java:77) 在 org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329) 在 org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309) 在 org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272) 在 org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243) 在 org.springframework.data.repository.query.parser.Part.(Part.java:76) 在 org.springframework.data.repository.query.parser.PartTree$OrPart.(PartTree.java:247) 在 org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:398) 在 org.springframework.data.repository.query.parser.PartTree$Predicate.(PartTree.java:378) 在 org.springframework.data.repository.query.parser.PartTree.(PartTree.java:86) 在 org.springframework.data.jpa.repository.query.PartTreeJpaQuery.(PartTreeJpaQuery.java:70) ...省略了43个常用框架
【问题讨论】:
标签: java hibernate spring-boot spring-data-jpa jhipster