Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. GET
  2. @RequestMapping(value = "/api/estabelecimentos", method = RequestMethod.GET, produces = "application/json")
  3. public @ResponseBody List<Estabelecimento> getAllEst() {
  4. return er.findAll();
  5. }
  6.  
  7. Delete
  8. @RequestMapping(method = RequestMethod.DELETE, value = "/api/estabelecimentos/{id}", produces = "application/json")
  9. public ResponseEntity<Estabelecimento> deleteEst(@PathVariable Long id) {
  10. er.deleteById(id);
  11. return new ResponseEntity<Estabelecimento>(HttpStatus.OK);
  12. }
  13.  
  14. POST
  15. @RequestMapping(method = RequestMethod.POST, value = "/api/estabelecimentos", produces = "application/json")
  16. public ResponseEntity<Estabelecimento> newEstabelecimento(@RequestBody Estabelecimento estabelecimento) {
  17. er.save(estabelecimento);
  18. return new ResponseEntity<Estabelecimento>(estabelecimento, HttpStatus.OK);
  19. }
  20.  
  21. PUT
  22. @RequestMapping(method = RequestMethod.PUT, value = "/api/estabelecimentos/{id}", produces = "application/json")
  23. public ResponseEntity<Object> updadeEstabelecimento(@RequestBody Estabelecimento esta, @PathVariable Long id){
  24. Optional<Estabelecimento> estab = er.findById(id);
  25.  
  26. if(!estab.isPresent())
  27. return ResponseEntity.notFound().build();
  28.  
  29. esta.setCod_Estabelecimento(id);
  30. er.save(esta);
  31. return ResponseEntity.noContent().build();
  32. }
  33.  
  34. Log Springboot
  35. 14:24:36.716 WARN 14320 --- [nio-8080-exec-1] .c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson deserialization for type [[simple type, class com.api.Entity.Estabelecimento]]: com.fasterxml.jackson.databind.JsonMappingException: Multiple back-reference properties with name 'defaultReference'
  36. 2019-05-22 14:24:36.720 WARN 14320 --- [nio-8080-exec-1] .c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson deserialization for type [[simple type, class com.api.Entity.Estabelecimento]]: com.fasterxml.jackson.databind.JsonMappingException: Multiple back-reference properties with name 'defaultReference'
  37. 2019-05-22 14:24:36.724 WARN 14320 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported]
  38.  
  39. Retorno Clien(Postman)
  40. "timestamp": "2019-05-22T17:24:36.740+0000",
  41. "status": 415,
  42. "error": "Unsupported Media Type",
  43. "message": "Content type 'application/json;charset=UTF-8' not supported",
  44. "trace": "org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supportedrntat org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:224)rntat org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:157)rntat org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:130)rntat org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgumen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement