Spring Boot 4 · Controllers and beans
Define a JPA entity
Map a class to a database table.
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
}
Official Spring Boot 4 documentation
More controllers and beans commands
- Write a REST controller
- Accept a JSON body
- Declare a service
- Create a repository
- Handle exceptions globally
All controllers and beans commands · Spring Boot 4 cheatsheet