Springboot from getting started to getting started (a demo)

wwz_ henu 2022-02-13 05:26:17 阅读数:505

springboot getting started getting started

One . Create project

There are two ways to create a project

1. Use Spring Initializr

visit : https://start.spring.io/

Check the corresponding configuration , You can download a compressed package , After decompression is demo project

On the right side , You can add dependency, Ash is often convenient

2. Use IntelliJ IDEA

New projects , choice  Spring Initializr

Check dependency, Very convenient

Both of the above methods can easily create a project

Two . add to Spring Web  

1. In the first step , Add... By checking

2. modify pom.xml

stay pom.xml Add the following

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

  3、 ... and . Add route

edit Demo1Application.java file

 

Four . function  

The console output is as follows

visit localhost:8080 

stay application.properties File for project configuration , The port number is configured as follows

server.port=8081

  Restart project ,localhost:8081

copyright:author[wwz_ henu],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130526144938.html