A Java-based REST API built with Spring Boot and MongoDB for managing "server" objects. The application allows users to create, retrieve, search, and delete server records via HTTP endpoints.
This project is ideal for learning REST API development with Java Spring Boot and MongoDB integration.
- ✅ Prerequisites
- ⚙️ Project Setup
- 🛠️ MongoDB Configuration
- 📁 Project Structure
- 📡 API Endpoints
- 🧪 Postman Testing
Ensure the following are installed on your system:
- Java JDK 17+
- Maven
- MongoDB (running locally or via MongoDB Atlas)
- Postman (for testing the API)
git clone https://github.com/<your-username>/<your-repo>.git
cd <your-repo>mvn clean installmvn spring-boot:runThe server will start on: 👉 http://localhost:8080
Make sure MongoDB is running locally.
Update the configuration in src/main/resources/application.properties:
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=Server_APIsrc/
├── main/
│ ├── java/ # Java source files for the main application
│ └── resources/ # Application resource files (e.g., configuration)
├── test/
│ ├── java/ # Test source files
│ └── resources/ # Test resource files
target/ # Compiled bytecode and build artifacts
.gitignore # Specifies files/directories ignored by Git
pom.xml # Maven configuration file
README.md # Project documentation (this file)
-
com.example.serverapi.ServerController REST controller classes that handle HTTP requests and responses.
-
com.example.serverapi.Server Data model classes representing server entities.
-
com.example.serverapi.ServerRepository Data access layer implementing MongoDB persistence logic.
-
com.example.serverapi.MongoConfig Configuration classes including MongoDB setup.
All key configuration files, such as application.properties, are located in:
src/main/resources/
--



