[JAVA] (Intellij) Hello World with Spring Boot

procedure

  1. In Intel iJ, "File"-> "New"-> "Project"
  2. Select "Spring Initializer" in the displayed New Project and click "Next".
  3. Enter "Group" and "Artifact" as appropriate. I want to deploy to the server, so select "War" for "Packaging" and click "Next"
  4. I want to create a web application, so check "Web" → "Spring Web" and click "Next"
  5. Enter "Project name" and "Project location" as appropriate, and click "Fisnish".
  6. Add the following to the automatically created Demo Application and execute.

I was addicted to the lack of @ RestController ...

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+ import org.springframework.web.bind.annotation.GetMapping;
+ import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
+ @RestController
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
+    @GetMapping("/hello")
+    public String sayHello() {
+        return "Hello World";
+    }
}

  1. When you access the URL below, "Hello World" should be displayed.

http://localhost:8080/hello

スクリーンショット 2020-07-26 12.53.06.png

Recommended Posts

(Intellij) Hello World with Spring Boot
(IntelliJ + gradle) Hello World with Spring Boot
Hello World with Spring Boot
Hello World with Spring Boot!
Hello World with Spring Boot
Until "Hello World" with Spring Boot
Hello world! With Spring Boot (Marven + text editor)
[Java] Hello World with Java 14 x Spring Boot 2.3 x JUnit 5 ~
Spring Boot Hello World in Eclipse
Hello World (REST API) with Apache Camel + Spring Boot 2
Hello World (console app) with Apache Camel + Spring Boot 2
[Practice! ] Display Hello World in Spring Boot
How Spring Security works with Hello World
Hello World with Micronaut
Download with Spring Boot
Compare Hello, world! In Spring Boot with Java, Kotlin and Groovy
Hello World at explosive speed with Spring Initializr! !! !!
Show a simple Hello World with SpringBoot + IntelliJ
Try to display hello world with spring + gradle
Generate barcode with Spring Boot
Implement GraphQL with Spring Boot
Get started with Spring boot
Run LIFF with Spring Boot
SNS login with Spring Boot
Hello World with VS Code!
File upload with Spring Boot
Spring Boot starting with copy
Spring Boot starting with Docker
Set cookies with Spring Boot
Use Spring JDBC with Spring Boot
Add module with Spring Boot
Getting Started with Spring Boot
Create microservices with Spring Boot
Send email with spring boot
Hello World with SpringBoot / Gradle
Hello, World! With Asakusa Framework!
Hello World comparison between Spark Framework and Spring Boot
Use Basic Authentication with Spring Boot
gRPC on Spring Boot with grpc-spring-boot-starter
Create an app with Spring Boot 2
Hot deploy with Spring Boot development
Database linkage with doma2 (Spring boot)
Spring Boot programming with VS Code
Inquiry application creation with Spring Boot
Hello world with Kotlin and JavaFX
Hello World with Docker and C
Get validation results with Spring Boot
Create a Hello World web app with Spring framework + Jetty
Create an app with Spring Boot
Google Cloud Platform with Spring Boot 2.0.0
Check date correlation with Spring Boot
Hello World with GlassFish 5.1 + Servlet + JSP
Create PDF with itext7 ~ Hello World ~
I tried GraphQL with Spring Boot
[Java] LINE integration with Spring Boot
Beginning with Spring Boot 0. Use Spring CLI
"Hello world" for ImageJ with Eclipse
I tried Flyway with Spring Boot
Hello World with GWT 2.8.2 and Maven
Message cooperation started with Spring Boot
Spring Boot gradle build with Docker