简体   繁体   中英

Spring Boot Paging not working

I am writing Spring Boot REST server.

This is my 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);
}

When compiled, testing phase I got this error :

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: There are test failures.

The full error report is here: https://pastebin.com/s4u5RX51

The problem is not the paging, the problem is it failed to connect to database while running your test suite. Could you paste your pom file as well as your application.properties (under test folder)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM