Skip to content

Latest commit

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Item API – Spring Boot REST Application

This project is a simple Java Spring Boot backend application that implements RESTful APIs to manage a collection of items. The application uses an in-memory data store (ArrayList) and does not require any external database.


Features

  • Add a new item
  • Retrieve an item by ID
  • Input validation using Jakarta Validation
  • In-memory data storage (ArrayList)

Technologies Used

  • Java 17
  • Spring Boot
  • REST APIs
  • Maven

Project Structure

src └── main ├── java │ └── com.example.demo │ ├── controller │ ├── service │ └── model └── resources └── application.properties


API Endpoints

1. Add Item

POST/items

Request Body

{
"id": 1,
"name": "Laptop",
"description": "Dell Laptop"
}
Response201Created – Item successfully added400Bad Request – Validation failure (missing required fields)2. Get Item by IDGET /items/{id}ExampleGET /items/1Response
{
"id": 1,
"name": "Laptop",
"description": "Dell Laptop"
}
200OK – Item found404Not Found – Item does not existBuilding and Running the Application LocallyPrerequisitesEnsure the following are installed on your system:Java 17Maven (or Maven Wrapper included in the project)Git (optional, for cloning the repository)Step 1: Clone the Repositorygit clone https://github.com/manjiri112/ItemAPI.gitcd ItemAPIStep 2: Build the ApplicationRun the following command from the project root directory:mvnw clean packageThis command:Cleans previous buildsCompiles the source codeRuns testsGenerates an executable Spring Boot JAR fileAfter a successful build, the JAR file will be created at:target/itemapi-0.0.1-SNAPSHOT.jarStep 3: Run the ApplicationStart the application using:java -jar target/itemapi-0.0.1-SNAPSHOT.jarYou should see logs indicating:Tomcat started on port 8080Started ItemApiApplicationStep 4: Access the APIThe application will be available at:http://localhost:8080Use Postman or any REST client to test the endpoints.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages