SPRING BOOT Install STS
SPRING BOOT
STS is an Eclipse based IDE for professionals who develop Java and Spring based applications.
Installing Spring Tool Suite (STS).
➔ STS is an eclipse based IDE that brings new Spring Boot related features along with existing features. Eclipse is a very popular IDE in the Java community.
➔ Installing Spring Tool Suite (STS) is a very simple and straightforward process.
Prerequisites for STS:
➔ The Java Development Kit (JDK) must be installed on the development system.
➔ Visit spring.io and check the JDK version requirements for the latest STS.
➔ To work with Spring Boot projects, a minimum of JDK17 is required but the latest is highly recommended.
Download the Java Development Kit (JDK)
➔ To download the JDK, go to the Oracle Java Release page Java Releases or download the latest JDK.
➔ Select the appropriate version according to the platform (windows/Linux/Mac).
➔ You may be asked to log in to download the JDK, please log in. If you don't have an Oracle account, create one and complete the download process.
Java Development Kit (JDK) Installation:
➔ To launch the setup wizard, double-click the downloaded jdk .exe file and follow the wizard's instructions until the installation is complete. This is a very simple process.
➔ To check if the installation was successful, issue the java -version command in the terminal. This will show the Java version installed on the system.
Check Java version installed in the system.
Download STS from the official website spring.io/tools#eclipse.
Extract the files
➔ Double-click the downloaded .jar file to start the self-extracting process. And after the extraction is complete, double-click the .exe file to open STS IDE.
➔ The self-extraction process may take some time, so be patient.
Open Spring Tool Suite (STS) IDE.
Create new project with Spring Starter Project.
Provide information to the Spring Starter project.
Select project dependency.
Note:Clicking the Finish button will create a new project.
Create Controller class.
Controller name HelloController.
Code for Controller
Syntax
package com.exam.helloworld;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/users")
public class HelloController {
@GetMapping(value="/hello")
public String helloHandler() {
return "GetMapping is working fine";
}
}
Run HelloworldApplication.java
If there is a error like bellow, change the server default port.
Change the server default port in application.properties file.
After successfully run HelloworldApplication.java.
Test Restfull api in the browser. Type localhost:8090/users/hello in address bar of a browser.