- This Example covers wriring simple & robust web services using HTTP Methods of GET & POST.
- Also covers Many To Many Real time example with Annotation.
- Experience towards loading properties from the configuration file at runtime.
- Proper way of handling exception & also code clean & maintainance
- Clinet App for testing the rest services.
You can then access Restfull here: https://github.com/Sudarshan-Gowda/Spring-Mvc-Rest-API-And-Client-App
Our issue tracker is available here: https://github.com/Sudarshan-Gowda/Spring-Mvc-Rest-API-And-Client-App/issues
The following items should be installed in your system:
- Tool - STS(Spring Toot Suite) or Eclipse
- Server - Apache Tomcat 7
- Database - MySQL
- Postman - Optional (Can use client API)
- Download this Project and do maven import.
git clone https://github.com/Sudarshan-Gowda/Spring-Mvc-Rest-API-And-Client-App.git
- To Import the Praject Using STS or Eclipse.
File -> Import -> Maven -> Existing Maven project
Spring Boot Configuration | Class or Java property files |
---|---|
The Main Class | RestController |
The Client APP | RestController |
Properties Files | application.properties |
Data Base Scripts Files | scripts.sql |
Sample Json | sample-json.txt |
- Once the application is installed properly, Run the application
- Once the application is deployed properly, Create schema and execute query into database. For scripts reference use the link scripts.sql
- Find the below exposed urls to test the application.
a. To fetch all the course details http://localhost:8090/Spring-Mvc-Rest-API-And-Client-App/getCourseDetails b. To fetch the course details by id http://localhost:8090/Spring-Mvc-Rest-API-And-Client-App/getCourseById/{id} c. To register the student (POST Method) http://localhost:8090/Spring-Mvc-Rest-API-And-Client-App/registerStudent { "student": { "stdFirstName":"Jennifer", "stdLastName":"L", "stdEmail": "[email protected]" } } d. To Opt/subscribe the Student Id with Course (POST Method) http://localhost:8090/Spring-Mvc-Rest-API-And-Client-App/optCourseForStudentById { "stdId":"1", "courseId":"1" } e. To fetch all Course and Student details http://localhost:8090/Spring-Mvc-Rest-API-And-Client-App/getAllCourseDetailsByStdId f. To remove or delete the Student from the course (POST Method) http://localhost:8090/Spring-Mvc-Rest-API-And-Client-App/deleteStudentOptCourseById { "stdId":"1", "courseId":"2" }
-
Application Landing Page: [click here] (https://github.com/Sudarshan-Gowda/Spring-Mvc-Rest-API-And-Client-App/blob/master/docs/picture1.png)
-
Client App Result Page: [click here] (https://github.com/Sudarshan-Gowda/Spring-Mvc-Rest-API-And-Client-App/blob/master/docs/picture9.png)
The issue tracker is the preferred channel for bug reports, features requests and submitting pull requests.