当我尝试使用@Postmapping在postaman中获取错误时,我在邮递员中为Restful services.in编写代码。
公共类BookController {
private BookRepository bookrepository;
@PostMapping("/addBook")
public String save(@RequestBody Book book)
{
bookrepository.save(book);
return "added book with id"+book.getId();
}
@GetMapping("/findAllBooks")
public List<Book> getBooks()
{
return bookrepository.findAll();
}
@DeleteMapping("/delete")
public String deleteBook(@PathVariable int id){
bookrepository.deleteById(id);
return "book deleted"+id;
}
}
当我遇到类似以下的错误时,我通过邮寄方式向邮递员发送请求时
{ “ timestamp”:“ 2019-03-27T12:22:20.319 + 0000”, “状态”:404, “错误”:“找不到”, “ message”:“无可用消息”, “ path”:“ / addBook” }