Spring Boot 4 · Controllers and beans
Create a repository
Get CRUD methods and derived queries without writing SQL.
public interface UserRepository extends JpaRepository<User, Long> {
Optional<User> findByEmail(String email);
}
Official Spring Boot 4 documentation
More controllers and beans commands
- Write a REST controller
- Accept a JSON body
- Declare a service
- Define a JPA entity
- Handle exceptions globally
All controllers and beans commands · Spring Boot 4 cheatsheet