From here, download the template with the following settings.
Project: Gradle Project Language: Java Spring Boot: 2.1.4 Dependencies: Web
Create HelloController.java.
HelloController.java
package com.example.demo;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("hello")
public class HelloController {
@GetMapping("")
public String index(Model model) {
return "Hello!!";
}
}
Click the green triangle in DemoApplication.java
to execute.
Go to http: // localhost: 8080 / hello.
Recommended Posts