"Spring Boot" is a very popular cutting edge technology used in corporate industry these days. It is a best platform to build and run a standalone application. It says just to build and run the application.
Today we will set up a brand new spring boot development environment and run a ultra simple project. Please refer below where we have explained each and every step.
First, we need to download the SPRING BOOT STS. Use this link to download the tool. Follow the below screen to download the correct version. It is available for all different OS platform. Just you need to click on "ZIP" - download will be started.
Second, Once download completed you will get a ZIP package in your downloaded folder. You should get sts-bundle inside the package. Copy that folder and paste in some drive - you feel to access from there later. We would suggest to place in C- drive.
Third, Once you placed the sts-bundle - it will be look like below screen. Also inside the folder - you should get the "sts-3.9.1.RELEASE" folder. Refer to the yellow marked STS icon. It will be used as a starter for Spring Boot Tool.
Forth, Now just double click on STS and open the tool like below screen.
Fifth, choose the work space for the project - as you use to choose for eclipse. Refer to the below screen-
That's all now you should have opened the tool in you system. Next step would be to create a simple project and run the application for the first time. You just need to follow my instructions as explained in below steps-
First, To create a project just open the window panel from the tool as explained in below image -
We will create a Maven project here.
Second, Check the box as marked in below image. click next.
Third, Provide group id, artifact id as explained in below image-
Forth, Once you clicked the FINISH button, you should have below project opened in STS -
Fifth, open pom.xml file and paste the below piece of code there. Once you shave saved the POM.XML all the jars will be downloaded and added to your project classpath. It's again a cool feature of Maven.
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.9.RELEASE</version>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
Now just update the project as shown below
You should have all jars downloaded and project tree should show like the below image -
Fifth, Now we will create the java class named as FirstApplication. You may refer the below image. Also make sure you have given proper package name.
Once you have clicked the Finish button pasted the below code to complete all of our coding -
package com.ncteam.firstapplication;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class FirstApplication {
public static void main(String[] args) {
//to start the spring boot application
SpringApplication.run(FirstApplication.class, args);
}
@RequestMapping("/hello")
public String sayHello() {
return "Hello NC Team, Welcome to Spring Boot Tutorials!";
}
}
That's all - we are all good to run our first project. Note - Spring Boot STS provided the in build Tom Cat server. So, Just build and run our first application. Refer to the below image -
Make sure to run as Java Application as of now. Once you clicked the above image button - you should get the below log screen. It means your application has been ready to run on tom cat.
Just got to your system browser and type the url -> http://localhost:8080/hello and hit enter. You should now get the below expected screen -
That's all we have successfully started our first application. You will learn the same in depth in our next tutorial. Stay tuned.. 😊😊
Please Donate Us @ https://imjo.in/t9cEFy
No comments:
Post a Comment