SpringBoot is currently the standard framework for Java development. In this article, we will look at how to quickly create a SpringBoot project.

The official website documents currently recommend two methods:

  1. By adding dependencies to your Maven or Gradle configuration files (if you have a Maven or Gradle project)
  2. Create via Spring Boot CLI (provided you download the Spring Boot CLI executable package)

IO/is also a quick way to create projects. Let’s try it to create and run a Spring Boot project.


Create a Spring Boot project

IO /, I tried to create a Java8-based Maven project for SpringBoot 2, entered the project information, added spring Web dependencies, and clicked the “GENERATE” button below to download the generated project zip.

Spring Initializr creates screenshots of the project

Hello World

After unpacking the package and importing the IDE (either IDEA or Eclipse, etc.), we can see the following directory structure:

SpringbootdemoApplication is project running entrance, there is a main method, start the project can be directly run the main method.

Appliation. properties is the configuration file for the project.

SpringBoot project structure diagram

\

Then we try to create a Controller:

@RestController public class DemoController { @GetMapping("/hello") public String hello(){ return "Hello World"; }}Copy the code

Run SpringbootdemoApplication to start the SpringBoot method, and then we enter http://localhost:8080/hello web pages to return to “Hello World”.

Example address

Small Western learning programming/Springbootdemo

Reference documentation

start.spring.io/

Docs. Spring. IO/spring – the boot…