Skip to content

SpringBoot-Begin-to-Advance/Spring_boot_model-controllers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Student API - Spring Boot

Overview

This is a simple Spring Boot application that provides APIs to manage student data. It includes endpoints to retrieve all students and filter students by their registration number.

Technologies Used

  • Java
  • Spring Boot
  • REST API

Endpoints

1. Get All Students

  • Endpoint: GET /api-student/get-all
  • Description: Retrieves a list of all students.
  • Response Example:
    [
        {
            "regNu": "2020-ict-01",
            "name": "sharada",
            "age": 25,
            "department": "ict"
        },
        {
            "regNu": "2020-ict-02",
            "name": "kanchana",
            "age": 25,
            "department": "ict"
        },
        {
            "regNu": "2020-ict-03",
            "name": "Liyanage",
            "age": 26,
            "department": "ict"
        }
    ]

2. Filter Student by Registration Number

  • Endpoint: GET /api-student/filter-by/{regNu}
  • Description: Retrieves student details based on the registration number.
  • Example Request: GET /api-student/filter-by/2020-ict-02
  • Response Example:
    {
        "regNu": "2020-ict-02",
        "name": "kanchana",
        "age": 25,
        "department": "ict"
    }

How to Run the Project

  1. Clone the repository:
    git clone https://github.com/sharada0417/Spring_boot_model-controllers.git
  2. Navigate to the project directory:
    cd Spring_boot_model-controllers
  3. Run the application using Maven:
    mvn spring-boot:run
  4. The API will be available at http://localhost:8080.

Issues and Fixes

1. filter-by/{regNu} may return null if no student matches

  • Solution: Ensure /api-student/get-all is called first to populate the list.
  • Alternative: Modify the method to return an error message instead of null.

2. Git Push Error: src refspec main does not match any

  • Solution:
    git add .
    git commit -m "Initial commit"
    git push -u origin main

Author

Sharada

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages