I want to develop Spring Boot with IntelliJ. Since the development project I am currently involved in is this combination, I built it to study the mechanism. I want to make a REST API that works with mysql.
--Environmental information - Windows10 - IntelliJ IDEA Community Edition 2019.1.1 - Spring Boot 2.1.5
Create a project template with Spring Initializr linked below. https://start.spring.io/
--Project: Select [Gradle Project] --Language: As it is --Spring Boot: As it is --Project Metadata: As is --Dependencies: Added [Spring Web Starter]
After completing the settings, click the "Generate the project" button at the bottom of the screen. The project zip will be downloaded, so unzip it.
DemoApplication.java
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemoApplication {
@RequestMapping("/")
String index(){
return "Hello World!";
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
From the Gradle window, execute Tasks → application → bootRun.
Post-execution console
Connect to http: // localhost: 8080 /
.
Hello World is output!
Recommended Posts