Hello World at explosive speed with Spring Initializr! !! !!

Purpose

Using SpringBoot, a Java framework, I want to output Hello World for the time being! I will leave it for those who say.

What is Spring Initializr?

You can easily generate a template application by selecting a build tool or development language on the browser. (I recognize it as something like scaffold in Ruby on Rails.)

Practical edition

Various versions handled this time

OS: macOS Mojave version 10.14.6 Text editor: Visual Studio Code (hereinafter VSCode)

$ java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
$ mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 13.0.2, vendor: N/A, runtime: /usr/local/Cellar/openjdk/13.0.2+8_2/libexec/openjdk.jdk/Contents/Home
Default locale: ja_JP, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
$ spring --version
Spring CLI v2.3.1.RELEASE

Go to Spring Initializr official !!!

Please visit here.

Make the following with various additions and corrections. スクリーンショット 2020-06-21 20.36.41.png

Then press the GENERATE button.

I think that the Zip file was downloaded by pressing the GENERATE button.

Extract the Zip file.

Fix with a text editor

スクリーンショット 2020-06-21 20.41.39.png

This time there should be a folder named demo, so open it in your text editor (this time it's VSCode).

This is a digression, but it is recommended that you install the following as an extension (work will be improved).

・ Java Extension Pack ・ Spring Boot Tools ・ Lombok Annotations Support for VS Code

Create HelloController.java in src / main / java / com / example / demo.

スクリーンショット 2020-06-21 21.16.45.png

While referring to the code of Spring Boot Official , Let's describe the contents of HelloController.java!

HelloController.java


package com.example.demo;
import org.springframework.boot.autoconfigure.*;
import org.springframework.web.bind.annotation.*;

@RestController
@EnableAutoConfiguration
public class HelloController {
  
  @RequestMapping("/")
    String home() {
        return "Hello World!";
    }
}

Then go to the demo folder in the terminal and Type mvn spring-boot: run.

Terminal


$ mvn spring-boot:run

[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> spring-boot-maven-plugin:2.3.1.RELEASE:run (default-cli) > test-compile @ demo >>>
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.

~abridgement~

After a while, the following will be displayed.

Terminal


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.1.RELEASE)

~abridgement~

Then in your browser http: // localhost: 8080 / When you enter

スクリーンショット 2020-06-21 21.23.37.png

Hello World! Is displayed!

At the end

This time, I have omitted detailed explanations such as Spring Boot. (The goal was to be able to display it on the browser)

We hope that you can use it for learning, such as changing the code yourself and checking it with a browser.

Recommended Posts

Hello World at explosive speed with Spring Initializr! !! !!
Hello World with Spring Boot
Hello World with Spring Boot!
Hello World with Spring Boot
Until "Hello World" with Spring Boot
(Intellij) Hello World with Spring Boot
Hello World with Eclipse + Spring Boot + Maven
How Spring Security works with Hello World
(IntelliJ + gradle) 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 ~
Try to display hello world with spring + gradle
Hello World with Micronaut
Spring with Kotorin ―― 1. SPRING INITIALIZR
Hello World (REST API) with Apache Camel + Spring Boot 2
Hit graph query with Java + PGX at explosive speed
Hello World (console app) with Apache Camel + Spring Boot 2
Hello World with VS Code!
Hello World with SpringBoot / Gradle
Hello, World! With Asakusa Framework!
Create a Hello World web app with Spring framework + Jetty
Spring Boot Hello World in Eclipse
Hello world with Kotlin and JavaFX
Hello World with Docker and C
Hello World with GlassFish 5.1 + Servlet + JSP
Create PDF with itext7 ~ Hello World ~
"Hello world" for ImageJ with Eclipse
Hello World with GWT 2.8.2 and Maven
Compare Hello, world! In Spring Boot with Java, Kotlin and Groovy
Processing at application startup with Spring Boot
Spring5 MVC Web App Development with Visual Studio Code Hello World Creation
Hello world with Java template engine Thymeleaf
Spring Boot2 Web application development with Visual Studio Code Hello World creation
[Practice! ] Display Hello World in Spring Boot
Java development with Codenvy: Hello World! Run
"Hello, World!" With Kotlin + CLI in 5 minutes
Hello world with Kotlin and Tornado FX
Build Zabbix server at explosive speed (CentOS 7)
Let's create a TODO application in Java 2 I want to create a template with Spring Initializr and make a Hello world
Spring Integration Study memorandum ~ Understanding Spring Integration Sample 1. Hello World ~
Hello World with JavaFX 11 (OpenJFX) in Liberica JDK 11
Run JSP Hello World with Tomcat on Docker
Show a simple Hello World with SpringBoot + IntelliJ
Use PHP + YoutubeDataAPIv3 at explosive speed using Docker-compose
Easy to display hello world with Rails + Docker
Read "Hello world"
Java, Hello, world!
Java Hello World
Hello World comparison between Spark Framework and Spring Boot