>PROBLEM
The application starts successfully, but the client fails to access the service getting 404.
Controller's original code:
@RestController
@RequestMapping("/api")
@CrossOrigin("*")
public class HelloController {
@Autowired
IHelloRepository helloRepository;
@GetMapping("/hellos")
public List
Sort sortByCreatedAtDesc = new Sort(Sort.Direction.DESC, "createdAt");
return helloRepository.findAll(sortByCreatedAtDesc);
}
>SOLUTION
***WRONG: @GetMapping("/hellos")
***RIGHT: @GetMapping("/hellos/")
@RestController
@RequestMapping("/api")
@CrossOrigin("*")
public class HelloController {
@Autowired
IHelloRepository helloRepository;
@GetMapping("/hellos/")
public List
Sort sortByCreatedAtDesc = new Sort(Sort.Direction.DESC, "createdAt");
return helloRepository.findAll(sortByCreatedAtDesc);
}
>ENV
Java 1.8
SpringBoot 1.5.6
No comments:
Post a Comment