SpringBoot entry cases (b)

The following is the CV to run introductory demo (fake test data)

First, create a project (maven create an empty project, not applicable here scaffolding created)

 

 

 

 

 

 

Second, add dependencies

  Note: SpringBoot provide a project called spring-boot-starter-parent's, which has been dependent on a variety of common (but not all) of version management, our project need to be the parent of this project works, so we do not worry about the version of the problem dependent, dependent on what is required, can be introduced directly into the coordinates!

  Import coordinate parent project

1 <parent>
2     <groupId>org.springframework.boot</groupId>
3     <artifactId>spring-boot-starter-parent</artifactId>
4     <version>2.1.6.RELEASE</version>
5 </parent>

 

  Adding web launcher: In order for SpringBoot help us complete a variety of automatic configuration, we must introduce automatic configuration dependent SpringBoot provided, we called 启动器. Because we are web project, where we introduce a web starter (no need to write the version number, as in the parent project has been ordained version)

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

 

 

Third, start writing class

 

 

 

 

Fourth, write controller

 

 

 

 

Fifth, start test test

When the starting class observed log

 

 

Test results directly in a browser

 

 

 

Guess you like

Origin www.cnblogs.com/vegetableDD/p/11555027.html