Incompatibility with Spring Boot 2.1: No default constructor for entity
jamescnewman opened this issue · 0 comments
If followed from the text (https://spring.io/guides/tutorials/rest/), as opposed to the pre-prepared project files in Git, this tutorial has been broken by the following change in Spring Boot 2.1:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes#lombok
Lombok
Spring Boot 2.1 has upgraded to Lombok 1.18.x from 1.16.x. In 1.18, Lombok will no longer generate a private, no-args constructor by default. It can be enabled by setting lombok.noArgsConstructor.extraPrivate=true in a lombok.config configuration file. For further information about changes in Lombok, please refer to its changelog.
This results in the following exception when attempting curl -v localhost:8080/employees
in the "HTTP is the Platform" section:
org.hibernate.InstantiationException: No default constructor for entity: : payroll.Employee
The "Getting Started" section of the tutorial instructs the student to use "Spring Initializr" to create a new project, which references the latest spring-boot-starter-parent, exposing students to the issue. The pre-prepared pom.xml in the git repository references 2.0.5, which is before the Lombok upgrade and doesn't experience the exception.