Make sure the User class is annotated with @Entity. This annotation tells Spring that…
Jump to turn (6)
- 1Make sure the User class is annotated with @Entity. This annotation tells Spring
- 2Make sure the User class is annotated with @Entity. This annotation tells Spring
- 3Check that the User class has a primary key field annotated with @Id. The primar
- 4adding the @ComponentScan annotation to the main application class, and specifyi
- 5adding the @ComponentScan annotation to the main application class, and specifyi
- 6adding the @ComponentScan annotation in this code. package net.crud.springbootcr
- User
Make sure the User class is annotated with @Entity. This annotation tells Spring that the User class is a managed entity that needs to be persisted in the database. import lombok.Data;
import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table;
@Data @Entity @Table(name = "users") public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "first_name") private String firstName; @Column(name = "last_name") private String lastName; }
- Assistant
As an AI language model, I cannot verify the correctness of the code above. However, the annotation @Entity should be enough to indicate to Spring that the User class is a managed entity that needs to be persisted in the database.
- User