Step 1: Create a Spring application
Create an empty application
Let’s start with backend based on the Spring Framework.
Go to the https://start.spring.io.
Use the following settings for project generation:
-
Since we already used
Maven
in Part 1 and Part 2, we will use it this time as a project builder again. -
The language of our backend project is Java.
-
Use the latest stable version of Spring Boot.
-
For consistency with the source code examples in this tutorial, set the following project metadata:
-
Group=
web.tutorial
, -
Artifact=
backend
, -
Name=
backend
, -
Description=
Supply Chain web service
, -
Package name=
web.tutorial.backend
.
-
-
Use 'Jar' packaging.
-
The Java version used is 17 (current LTS).
-
Add 'Spring Web' as the only dependency.
Click "Generate" and download the archive. Unpack the archive with the application on your local disk.
Open the created Spring project
In Eclipse
If you are using Eclipse IDE, choose:
File – Import – Maven – Existing Maven Project

In the selection window that follows, click “Browse” and select the folder where you unpacked the template project.

Eclipse will find the pom.xml
file.
Now you only need to agree by clicking the "Finish" button.
The project should be imported successfully and you should see something like this:

"Hello, World"
Let’s create our first controller that responds with the traditional “Hello, World”.
Create a new package web.tutorial.backend.controller
.
Inside that package, create a new FastExperimentController
class:
package web.tutorial.backend.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/")
public class FastExperimentController {
@GetMapping(value = "/hello")
public String hello() {
return "Hello, World";
}
}
Check the result
Run the application.
If you are using IntelliJ IDEA, then select Run BackendApplication.class main() in the context menu of the BackendApplication file.
If you are using Eclipse, select Run as – Java Application .
The application should start.
|
Now open your browser and enter the address http://localhost:8080/hello. You should see the “Hello, World” string:
