@Repository
public interface ICommentRepository extends PagingAndSortingRepository<Comment, Integer> {
@Query(from Comment comment where comment.article.id = ?1)
Page<Comment> findAllArticleId(int articleId, Pageable page);
}
报错:The annotation @Query is disallowed for this location
解决方法:
首先要正确导入Query,
然后发现
@Query(from Comment comment where comment.article.id = ?1)
这一行少了""
改为
@Query("from Comment comment where comment.article.id = ?1")