简体   繁体   English

Postman showing empty JSON object from spring boot rest api

[英]Postman showing empty JSON object from spring boot rest api

public class UserController {
@Autowired
private UserRepository userRepository;

@GetMapping
public List<User> findAllUsers() {
    return (List<User>) userRepository.findAll();
}

} }

This is the code of the controller class这是 controller class 的代码

you specified the url in the @RequestMapping("...") annotation您在@RequestMapping("...")注释中指定了 url

@RequestMapping("url")
public class UserController {
@Autowired
private UserRepository userRepository;

@GetMapping
public List<User> findAllUsers() {
    return (List<User>) userRepository.findAll();
}

and add the @RestController annotation above the class并在 class 上方添加@RestController注释

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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