This is a Spring Boot project demonstrating CRUD operations with MongoDB. The project includes various endpoints to manage student records.
-
Clone the repository:
git clone https://github.com/Anyel-ec/SpringBoot-ORM-MongoDB-DTO cd SpringBoot-ORM-MongoDB-DTO
-
Build the project:
mvn clean install
-
Run the application:
mvn spring-boot:run
Ensure you have MongoDB installed and running on your local machine. The default configuration expects MongoDB to be running on localhost:27017
. You can modify the MongoDB settings in the application.properties
file if necessary.
spring.application.name=Introduce-CRUD-MongoDB
springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true
# Define the path for swagger-ui
springdoc.swagger-ui.path=/swagger-ui.html
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=introduce_mongo
├── src
│ ├── main
│ │ ├── java
│ │ │ └── top.anyel.mongo
│ │ │ ├── collections
│ │ │ │ ├── Student.java
│ │ │ │ └── dto
│ │ │ │ ├── StudentDto.java
│ │ │ │ ├── StudentExistingDto.java
│ │ │ │ └── StudentNewDto.java
│ │ │ ├── controller
│ │ │ │ ├── DocController.java
│ │ │ │ └── StudentController.java
│ │ │ ├── exception
│ │ │ │ └── GlobalExceptionHandlerController.java
│ │ │ ├── repository
│ │ │ │ └── StudentRepository.java
│ │ │ ├── service
│ │ │ │ ├── StudentService.java
│ │ │ │ └── StudentServiceImpl.java
│ │ │ └── IntroduceCrudMongoDbApplication.java
│ │ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── top.anyel.mongo
│ └── IntroduceCrudMongoDbApplicationTests.java
└── pom.xml
POST /students/add
- Add a new studentPOST /students/update
- Update an existing studentDELETE /students/{studentId}/delete
- Delete a student by IDGET /students/{studentId}
- Get a student by IDGET /students/all
- Get all students with pagination
GET /doc/
- Redirect to Swagger UI
POST /students/add
{
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"contactNumber": "1234567890",
"courseName": "Computer Science"
}
POST /students/update
{
"id": "60d5f9b3e1b8f9262c8a5e9c",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"contactNumber": "0987654321",
"courseName": "Software Engineering"
}
GET /students/60d5f9b3e1b8f9262c8a5e9c
DELETE /students/60d5f9b3e1b8f9262c8a5e9c/delete
GET /students/all?page=0&size=30&sort=modified,DESC
If you would like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/new-feature
). - Make your changes and commit them (
git commit -am 'Add new feature'
). - Push your branch (
git push origin feature/new-feature
). - Create a Pull Request.
This project is licensed under the ISC License. See the LICENSE
file for details.