[JAVA] Hello World with SpringBoot / Gradle


Directory structure

See below. image.png

build.gradle I will describe the definition in build.gradle referring to here.


plugins {
    id 'org.springframework.boot' version '2.3.3.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'

group 'org.example'
version '1.0-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {

def defaultEncoding = 'UTF-8'
tasks.withType(AbstractCompile) each { it.options.encoding = defaultEncoding }

compileTestJava {
    options.encoding = defaultEncoding

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'

test {

Reimport in the right pane Gradle. image (1).png

Hello World Listed in two classes.


package org.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class BootApp {

    public static void main(String[] args) {
        SpringApplication.run(BootApp.class, args);


package org.example;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

public class Controller {

    public String index() {
        return "\nHello World!";

Run BootApp.java and check with GitBash.

$ curl http://localhost:8080/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    13  100    13    0     0    149      0 --:--:-- --:--:-- --:--:--   149
Hello World!


Unify character code to utf8 with gradle

Recommended Posts

Hello World with SpringBoot / Gradle
Hello World with Micronaut
(IntelliJ + gradle) Hello World with Spring Boot
Try to display hello world with spring + gradle
Hello World with Spring Boot
Hello World with Spring Boot!
Hello World with VS Code!
Hello World with Spring Boot
Hello, World! With Asakusa Framework!
Until "Hello World" with Spring Boot
Hello world with Kotlin and JavaFX
Hello World with Docker and C
(Intellij) Hello World with Spring Boot
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
Hello world in Java and Gradle
Make a simple CRUD with SpringBoot + JPA + Thymeleaf ① ~ Hello World ~
Hello World with Eclipse + Spring Boot + Maven
Hello world with Java template engine Thymeleaf
Until you run Hello World of JavaFX with VS Code + Gradle
Try Hello World with the minimum configuration of Heroku Java spring-boot
Java, Hello, world!
Java development with Codenvy: Hello World! Run
"Hello, World!" With Kotlin + CLI in 5 minutes
Java Hello World
Hello world with Kotlin and Tornado FX
How Spring Security works with Hello World
Make SpringBoot1.5 + Gradle4.4 + Java8 + Docker environment compatible with Java11
Hello World with JavaFX 11 (OpenJFX) in Liberica JDK 11
Hello world! With Spring Boot (Marven + text editor)
Hello World at explosive speed with Spring Initializr! !! !!
Run JSP Hello World with Tomcat on Docker
Until you install Gradle and output "Hello World"
[Java] Hello World with Java 14 x Spring Boot 2.3 x JUnit 5 ~
Easy to display hello world with Rails + Docker
Integration Test with Gradle
"Hello World" in Java
Java Learning (1)-Hello World
Hello world in node.js
Install Gradle with ubuntu16.04
Hello World in Java
DataNucleus starting with Gradle
Studying Java-Part 1-Hello World
Supports multi-port with SpringBoot
Use WebJars with Gradle
Get started with Gradle
Use jlink with gradle
Hello World (REST API) with Apache Camel + Spring Boot 2
Hello World (console app) with Apache Camel + Spring Boot 2
Gradle + Kotlin-Generate jar with DSL
[Java] One type of alphabet prohibited With binding Hello, world! [Binding]
Hello World with Ruby extension library for the time being
[Vue Rails] "Hello Vue!" Displayed with Vue + Rails
Lombok not working with Gradle5
Create a Hello World web app with Spring framework + Jetty
java hello world, compile, run
Remote debugging with Gradle test
Java beginners read Hello World
Use log4j2 with YAML + Gradle