I'm working on a rest web service based on spring boot ,I'm using lombok for generating getter and setter but when I called my web service I get my object with fields with default values null this my code :
My entity :
@Data
@Entity
@JsonAutoDetect(fieldVisibility = Visibility.ANY)
public class Projet implements Serializable {
/**
* Serial UID
*/
private static final long serialVersionUID = -7268509549664338191L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long codeProjet ;
private String description;
private String responsable ;
private Double budget ;
private Date dateDebut;
private Date dateFin ;
@OneToMany(mappedBy="codeQuestonnaire")
@JsonIgnore
private List<Questionnaire> questionnaires ;
}
This my rest service :
@RestController
public class ProjectResource {
@Autowired
private ProjetRepository projetRepository ;
@GetMapping("/projet/{id}")
public ResponseEntity<Projet> getProjet(@PathVariable("id") long id){
Projet projet = projetRepository.getOne(id);
if(projet!=null) {
return new ResponseEntity<Projet>(projet,HttpStatus.OK);
}else {
return new ResponseEntity<Projet>(HttpStatus.NOT_FOUND);
}
}
}
In my configuration file I added this line :
spring.jackson.serialization.fail-on-empty-beans=false
When I called my service I get this response :
{"codeProjet":null,"description":null,"responsable":null,"budget":null,"dateDebut":null,"dateFin":null,"handler":{},"hibernateLazyInitializer":{}}
If I added getters and setters to my class it works correctly and I get json response with values Thanks in advance for any help