How to create a Spring Boot REST API in 15 minutesRakesh Narang·Follow2 min read·May 3, 2020--ListenShareHey guys,Follow me on insta: https://www.instagram.com/global.software.developers/?hl=enHow to build a simple rest API using spring boot and javaPrerequisite for this tutorial is that you have java and eclipse installed on your systemStep 1Open your eclipseRight-click on the project explorer tabAnd create a new project of type otherStep 2A wizard will openIn the search section of the wizard, type mavenFrom the filtered options, select maven option and click on nextStep 3Checkmark the box that says create a simple archetype maven project and click on nextStep 4In group idArtifact idNameAnd descriptionType the name of your projectIn my case the name of the project is helloworldprojAnd click on finishStep 5Open googleType in spring boot web starter dependencyOpen mvnrepository linkClick on the latest release dependency and copy the maven dependencyAs shown in the screenshotStep 6Open pom.xml of helloworldproj that you createdBefore project closing XML tag, create a dependencies XML tagWithin dependencies, XML tag, paste the dependency that you copied from mvnrepositorySave the fileSelect the project and refresh the projectOn mac, 💻 the short key for a refresh is fn + opt + f5On windows, I think it is alt + shift + f5Refreshing the project will download all the dependency jars mentioned in the spring boot web started bundleStep 7Now right click on src/main/java folderClick ok create a new packageAnd create two packages with names:-One with the name “main”And one with name “main.controllers”Step 8Your project’s folder structure will now look something like this picStep 9In the main package, create an Application.class with a main methodAnnotate class with @SpringBootApplicationAnd in the main method, write SpringApplication.run(Application.class, args);When you run this main method as a java program, your web server will come up on your local systemStep 10In the main.controllers packageCreate a HelloWorldController.java fileAnnotate it with @RestControllerProvide an @RequestMapping and give it a value /This is also known as the root controllerNow create an @GetMapping method in the file and simply return a “Hello World” string from itThat’s it, we’re done with the coding partStep 11Now go to Application.java fileRight-click on the main method and run it as a java programThis will start the embedded tomcat server and your first REST API will be deployed on your local systemStep 12When you will run your spring boot app like a java program, the following logs will be generated in the consoleBy default your spring boot app with start at port 8080Step 13The final step is to check that your rest API is working as expectedFor that, open any browser and type in localhost:8080The browser will display Hello World textThis is how you create a hello world rest API!More tutorials to come!Keep following and share in your story for your friends to learn too !!This marks the end of the spring boot basic rest api hello world tutorial !If you have any doubts, leave a comment, or directly dm me !I hope this tutorial was useful for you, if you did find it useful, consider sharing it in your story for your friends to see and learn too !Best Regards,RakeshFollow me on insta: https://www.instagram.com/global.software.developers/?hl=en