SDR /搜索映射冲突
SDR /search mapping collision
我正在使用 Spring Data REST 和 Spring Boot 1.5.4,我遇到了麻烦。
我定义了存储库:
public interface TicketRepository extends JpaRepository<Ticket, Long> {
@RestResource(path = "find-by-ticket-list-id")
Page<Ticket> findByTicketListIdOrderByPosition(@Param("ticketListId") Long ticketListId, Pageable pageable);
}
我需要一个特定的 GET 方法。所以我定义了控制器:
@RepositoryRestController
public class TicketController {
@GetMapping("/tickets/{id}")
public ResponseEntity<?> getTicket(@PathVariable Long id, PersistentEntityResourceAssembler assembler) {
...
}
}
现在,当我尝试获取搜索资源列表时,出现错误
Failed to convert value of type 'java.lang.String' to required type
'java.lang.Long'
我知道这是由于 /tickets/{id}
和 /tickets/search
的冲突,但我不知道如何处理。我试着把 @Order
放在 getTicket
方法之前和 TicketController
定义之前,但它没有改变任何东西。
如何解析两个 URI?
在 URI 模板模式中使用正则表达式:
@GetMapping("/tickets/{id:\d+}")
public ResponseEntity<?> getTicket(@PathVariable Long id, PersistentEntityResourceAssembler assembler) {
...
}
More info...
我正在使用 Spring Data REST 和 Spring Boot 1.5.4,我遇到了麻烦。
我定义了存储库:
public interface TicketRepository extends JpaRepository<Ticket, Long> {
@RestResource(path = "find-by-ticket-list-id")
Page<Ticket> findByTicketListIdOrderByPosition(@Param("ticketListId") Long ticketListId, Pageable pageable);
}
我需要一个特定的 GET 方法。所以我定义了控制器:
@RepositoryRestController
public class TicketController {
@GetMapping("/tickets/{id}")
public ResponseEntity<?> getTicket(@PathVariable Long id, PersistentEntityResourceAssembler assembler) {
...
}
}
现在,当我尝试获取搜索资源列表时,出现错误
Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'
我知道这是由于 /tickets/{id}
和 /tickets/search
的冲突,但我不知道如何处理。我试着把 @Order
放在 getTicket
方法之前和 TicketController
定义之前,但它没有改变任何东西。
如何解析两个 URI?
在 URI 模板模式中使用正则表达式:
@GetMapping("/tickets/{id:\d+}")
public ResponseEntity<?> getTicket(@PathVariable Long id, PersistentEntityResourceAssembler assembler) {
...
}
More info...