Spring Boot is mainly used for rapid application developement and offers a fast way to build applications . It was initially released in 2014 and is used to create Spring-powered, production-grade applications. It is convention over configuration extension and it comes with embedded web server(Tomcat) out of the box with nearly no XML Configuration and leads to minimal explicit configuration.
If any Eclipse IDE is not installed, it can be installed using this STS5 installation tutorial in Linux or if there being any other Operating System being used this link is to be referenced for installation.
Below is a simple tutorial to implement Spring Boot which is beginner friendly:
1. First any Eclipse IDE is to be opened like Eclipse or STS(Spring Tool Suite)
Then workspace of choice is to be launched
2. There are two options for creating Spring Boot project, first lets follow the basic step of creatin the project by following steps: File > New > Spring Starter Project
Make sure there is internet connection for the below form to appear, next it requires to name the project and it is to make sure that Maven(build tool type) is selected
Next it requires searching the Spring Web dependency and clicking finish
By now if above steps as in step 2 are followed and project is created, then one can directly jump to step 3 by skipping below optional alternate instructions.
Here is another option for creating the Spring Boot Starter Project, by using Spring Initializer Web App to create Spring Starter Project, Spring Web dependency is to be added.
Next after generating the project it will be generated in compressed form, all it requires is to extract it and then importing it in our IDE as a maven project as depicted below:
Choosing Existing Maven Projects
And then browsing the extracted directory generated from Spring Initializr
3. For checking if Project is successfully created, the project structure can be seen in the Package Explorer as provided below
4. Navigating main progam file to check the project main function
5. Next step requires creating the Controller file in the same package as in the main function class as provided below
Then it requires naming the class as RestControllerTest and clicking Finish Button
@RestControllerpublic class RestControllerTest {@GetMapping("/")public String home() {return "<h1>Home</h1>";}@GetMapping("/test-success")public String testSpringBootApplication() {return "<h1>Spring Boot Test Success</h1>";}}
7. Next it requires navigation to main file that is TestSpringbootApplication.java for running the app
8. Next it requires to right clicking and choosing the Run As > 3 Spring Boot App
9. Next to check the program success output, try navigating the "localhost:8080" route in the browser


















No comments:
Post a Comment