java - Create endpoint from query by method name, that is pageable/sortable
问题描述
I'm very new to spring boot, and I have a simple CRUD service that has a RestRepositoryResource
:
@RepositoryRestResource
public interface CatalogueOrderRepository extends JpaRepository<CatalogueOrder, Long>,
QuerydslPredicateExecutor<CatalogueOrder> {
}
I'm trying to create a custom endpoint, that can perform a pageable/sortable query for order statuses NOT equal to the provided query parameter. I attempted the following:
@GetMapping("/test")
Page<CatalogueOrder> findByOrderStatusNot(String orderStatus, Pageable page);
When I attempt to hit the endpoint /test
, I get a 404 error.
Am I exposing the endpoint wrong? And if so, have I defined the method correctly for what I am trying to achieve?
解决方案
也许您忘记@RestController
在控制器中设置注释。
这样做并尝试再次调用http://localhost:8080/test
,
推荐阅读
- javascript - 为 React 中的每个元素制作独特的 NavLink 很热?
- azure - 具有复制范围 USG 的租户的公共端点不支持机密客户端请求
- c++ - MSYS2 MinGW在构建大型应用程序时奇怪的多重定义boost::exception_detail::clone_impl
- kubernetes - 通过特定用户从远程服务器访问 K8S 主服务器
- sql-server - 在动态 SQL 中使用变量
- javascript - 编辑 Google Doc 然后转换为 PDF 的脚本
- flutter - 根据 Flutter 中的滚动位置更改容器的宽度
- scrapy - 带有“部署失败(400)”的scrapyd-deploy
- python - 如何在python中将行的每个元素转换为列?
- date - 在 DOM 中的日期之间变得不同