[Spring Boot] How to create a project (for beginners)

What to do this time

  1. Create a SpringBoot + Java8 + gradle project.
  2. After accessing localhost: 8080 in chrome, display "Hello World".

environment

--IntelliJ (free)

Prototype a project with Spring Initializr

--Open the official page of Spring Initializr.  2019-10-01 17.27.51.png ――Here, select the elements you need and create them.  2019-10-01 17.28.40.png  2019-10-01 17.29.00.png --When you have made your selection, click the Generate button.  2019-10-01 17.29.32.png --A zip will be created in the location you specified, so unzip it.  2019-10-01 17.30.18.png

Open project in IntelliJ

--Open the folder you just unzipped.  2019-10-01 17.31.01.png --Right-click on the build.gradle file and open it in IntelliJ.  2019-10-01 17.31.42.png  2019-10-01 17.32.11.png

Show Hello World

--Without any modification to the SampleApplication class created in the early stages Create a new Controller class in the same directory as the SampleApplication class.

HelloController.java


@RestController
public class HelloController {

   @GetMapping("/")
    public String index() {
        return "hello world";
    }

    @PostMapping("/")
    public String index2() {
        return "Hello";
    }

--When you access "localhost: 8080", the GET method is called and The characters are displayed.  2019-10-01 17.52.39.png

important point

--Thymeleaf is not required. --When you make a change to the code, you have to press "■ (Stop)". Since it will be started multiple times, let's erase it one by one and then run "▶". --When you want to create RestAPI, not "@Controller" Let's add "@RestController".

Recommended Posts

[Spring Boot] How to create a project (for beginners)
How to create a Spring Boot project in IntelliJ
How to make a hinadan for a Spring Boot project using SPRING INITIALIZR
How to create a Maven repository for 2020
How to create a database for H2 Database anywhere
How to create pagination for a "kaminari" array
How to add a classpath in Spring Boot
[1st] How to create a Spring-MVC framework project
How to create a method
How to set Dependency Injection (DI) for Spring Boot
How to display characters entered in Spring Boot on a browser and reference links [Introduction to Spring Boot / For beginners]
How to set Spring Boot + PostgreSQL
[Java] How to create a folder
How to use ModelMapper (Spring boot)
How to make a Maven project
Tutorial to create a blog with Rails for beginners Part 1
How to create a lightweight container image for Java apps
Tutorial to create a blog with Rails for beginners Part 2
Introducing Spring Boot2, a Java framework for web development (for beginners)
How to create and launch a Dockerfile for Payara Micro
Tutorial to create a blog with Rails for beginners Part 0
From building an AWS cloud environment to deploying a Spring Boot app (for beginners)
Must-see for beginners! How to manage your Xcode project on Github
How to create a new Gradle + Java + Jar project in Intellij 2016.03
How to create your own Controller corresponding to / error with Spring Boot
Create Java Spring Boot project in IntelliJ
[Ruby] How to use slice for beginners
[Swift5] How to create a splash screen
[rails] How to create a partial template
How to split Spring Boot message file
[For beginners] How to debug in Eclipse
Create a Spring Boot project in intellij and exit immediately after launching
Create a Spring Boot app development project with the cURL + tar command
How to build a Ruby on Rails environment using Docker (for Docker beginners)
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
How to create a server executable JAR and WAR with Spring gradle
[For internal use] For those assigned to the Spring Boot project (under construction)
[Java] [For beginners] How to insert elements directly in a 2D array
Steps to create a simple camel app using Apache Camel Spring Boot starters
Create a website with Spring Boot + Gradle (jdk1.8.x)
Book introduction: Spring Boot Recommended reference book for beginners!
Create a simple search app with Spring Boot
[Rails] How to create a graph using lazy_high_charts
How to use MyBatis2 (iBatis) with Spring Boot 1.4 (Spring 4)
Run a Spring Boot project in VS Code
How to make Spring Boot Docker Image smaller
How to use Spring Boot session attributes (@SessionAttributes)
Create a Spring Boot application using IntelliJ IDEA
How to create a class that inherits class information
[For beginners] How to implement the delete function
How to create a theme in Liferay 7 / DXP
How to make a lightweight JRE for distribution
Java tips-Create a Spring Boot project in Gradle
How to easily create a pull-down in Rails
[Rails] How to create a Twitter share button
How to bind to property file in Spring Boot
Create a web api server with spring boot
[For super beginners] How to use autofocus: true
[Spring Boot] How to refer to the property file
Spring Boot --How to set session timeout time
Create a Spring Boot development environment with docker