【问题标题】:Spring Boot Paging not workingSpring Boot 分页不起作用
【发布时间】:2017-04-21 17:42:27
【问题描述】:

我正在编写 Spring Boot REST 服务器。

这是我的 TripController.java

@RequestMapping(path = "/", method = RequestMethod.GET)
public GenericResponse<List<Trip>> getUserTrips(@RequestParam("owner") String owner) {
    Pageable pageRequest = createPageRequest();
    List<Trip> trips = tripRepository.findByOwner(owner , pageRequest);
    return new GenericResponse<List<Trip>>(200, "Success", trips);
}

private Pageable createPageRequest()
    return new PageRequest(0, 10);
}

在编译,测试阶段我得到了这个错误:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project demo: 有测试失败。

完整的错误报告在这里:https://pastebin.com/s4u5RX51

【问题讨论】:

    标签: java rest spring-boot pagination


    【解决方案1】:

    问题不在于分页,问题在于运行测试套件时无法连接到数据库。 您能否粘贴您的 pom 文件以及您的 application.properties(在 test 文件夹下)?

    【讨论】:

      猜你喜欢
      • 2019-01-20
      • 2019-02-05
      • 2018-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-17
      • 1970-01-01
      相关资源
      最近更新 更多