Continuing from the previous session.
The article is divided into three parts. 1. MVC model description 2. From STS introduction to Japanese by Pleiades 3. From project creation to checking the page on the local host ← now here Has become.
This time from creating the project to checking the page on the local host.
This time, create a project with Spring-Boot. When creating a Spring application from scratch, you have to set up a lot of settings and functions yourself, but Spring-Boot does that automatically.
Go to File> New> Spring Starter Project from the STS menu.
In the Create Project window that appears, change the type setting from Maven to Gradle and the package from Jar to War. Gradle can choose Buildship 2.x or 3.x, but basically I think 3.x is good. Gradle is a system that automates builds. If you describe the settings at the time of build in the .gradle file, the War(Jar) file will be built according to the settings. Some automation systems include Maven and Ant.
Other than that, do not change anything and proceed to the next. Since the dependency setting screen appears, select Thymeleaf and Spring Web.
I think that clicking the Finish button will close the compose window and return to the first screen. After a while, the project will be created in the Package Explorer on the left. This time there is no big change, so it should be called “demo”.
Create HTML file
Create an HTML file to display next. But you don’t have to write the code from scratch. STS provides various file templates. If you open the folder src/main/resources from the project tree, I think there is a package called templates inside. Right-click on it and select New> Other.
Then a window for creating a new one is displayed. Select Web> HTML file from it and click Next.
Move to the screen to select the parent folder, but do not touch it, change only the file name from default NewFile.html to index.html. Then click the Finish button.
Then, index.html file will be created directly under templates. All the parts necessary to display the page are written from the beginning, so let’s additionally display “Hello, World!”.
Finally right-click on the project and select Run> Spring Boot App.
If you see “Started DemoApplication in xxx seconds” after some logs on the console screen below, the localhost should have been booted up successfully.
To check the page, in the address bar of your favorite browser http://localhost:8080 Type in. It is displayed properly.
If the local host is left as it is, it will still start up, so check the page and press the stop button (blue circle in the image) to stop it. It doesn’t matter whether you press the up or down button.
The above is a simple flow from introducing STS to displaying a web page. Actually, we have to add libraries and change properties, and we also need to connect to a database, so I will write about it again.