Install Spring Tools 4
--Find STS4 in the Eclipse market and press install
--Press Confirm
--Select "I accept the terms of the Terms of Use" and press Finish
--Press Restart Now to restart Eclipse
--Select "Window-> Perspective-> Open Perspective-> Other" from the menu
--Select Spring and press Open
--Select Spring from the perspective
--Select the menu "File-> New-> Spring Starter Project"
--Press Next
--Add a dependency and press Finish
--Wait for dependency import
--If you get an unknown error in the first line of pom.xml, add the version specification of maven plugin.
pom.xml
<properties>
<java.version>1.8</java.version>
<!--Add the line below-->
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
Create a Controller
HelloController.java
package com.example.demo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HelloContoller {
@RequestMapping("/")
public String hello() {
return "hello";
}
}
Create HTML
hello.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Spring demo</title>
</head>
<body>
<h1>Hello</h1>
</body>
</html>
Select "Run-> Spring boot application" from the toolbar execution to access "http: // localhost: 8080"
Recommended Posts