Spring Boot provides seamless integration with JPA (Java Persistence API) and Hibernate for handling database operations.
Spring Boot uses Spring Data JPA, which simplifies database interactions with less boilerplate code.
pom.xml
)application.properties
✅ spring.jpa.hibernate.ddl-auto=update
create
: Creates tables every time (deletes old data).update
: Updates schema (recommended).none
: No automatic changes.User.java
)UserRepository.java
)✅ Spring Data JPA automatically provides CRUD operations!
findAll()
, findById(id)
, save(entity)
, deleteById(id)
.UserService.java
)UserController.java
)Run the application using your IDE or with the following Maven command:
Spring Boot starts an embedded Tomcat server (default: http://localhost:8080
).
Once the application is running, test the endpoints: