Maven project development steps (2) Based on the springboot

1, first of all we need to add the web rely on pom.xml file. Add the following to rely on the <dependencies> tag. Figure

     <dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

     </dependency>

image.png

2. Next, we create TestController class, Testuser class, there is a JSONResult class. Structured as follows:

image.png

(. 1) the Testuser user class is a class of our simulations: wherein, @JsonFormat (pattern = "the MM-dd-YYYY HH: mm: SS A", the locale = "ZH", TimeZone = "GMT +. 8") may be date type data into a specific format (for example: the MM-YYYY-dd); @JsonInclude (Include.NON_NULL) indicates if the attribute value is null, will not be displayed on the page.

image.png

(2) JsonResult class is the class may return a result output in JSON form:

Specific file download link to My Drive:

Link: https: //pan.baidu.com/s/1z-zpdBSbcNjXYXfqljL17g 

Extraction code: 88bp 

(. 3) TestController categories:

image.png

3, so we have to test the project, right-click on the selected item → → run as → java application. After a successful start, we enter the address in the browser: HTTP: // localhost: 8080 / the Test / the Hello , press Enter to see our user information. Figure:

image.png

4, such a basic web project can be run.

Guess you like

Origin blog.51cto.com/13082457/2431441