This is a simple Spring Boot CRUD (Create, Read, Update, Delete) application using Spring Data JPA, PostgreSQL, Flyway for database migration, Springdoc OpenAPI for API documentation, and Swagger for interactive API exploration.
- Java 17
- Maven
- PostgreSQL (with a database named
crud-db
and userpostgres
with password6262
)
-
Clone the repository:
git clone https://github.com/ranasl62/spring-boot-crud.git
-
Navigate to the project directory:
cd spring-boot-crud
-
Build the project:
mvn clean install
-
Run the application:
mvn spring-boot:run
The application will be accessible at https://localhost:8080.
Flyway is used for database migration. Ensure that your PostgreSQL database is running, and Flyway will automatically create the necessary schema and tables on application startup.
API documentation is generated using Springdoc OpenAPI and Swagger. You can access the Swagger UI for interactive API exploration at https://localhost:8080/swagger-ui/index.html.
- GET /api/users: Retrieve all users.
- GET /api/users/{id}: Retrieve a user by ID.
- POST /api/users: Create a new user.
- PUT /api/users/{id}: Update a user by ID.
- DELETE /api/users/{id}: Delete a user by ID.
The project includes basic unit tests. You can run the tests using:
mvn test
Feel free to contribute to the project by opening issues or submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.