spring boot test result and use plug-style Example 1 & Packaging start

This section content:

1: spring boot using a small plug-in

2: Construction of a simple example of the result of style and access

3: After the start of the project and access labeled jar package.

One: Adding boot devtools plug-ins:

image1.png

After execution, view the pom.xml:

image2.png


Re-pom, xml file will be more of a dependent.

The role of this tool:

When not in use the plug-in, and then if we want to add a new method in IndexController in, first shut down tomcat server before coding, coding is complete, restart tomcat can access.

Source: Kaige Java (kaigejava). www.kaigejava.com

The benefits of using the plug-in:

In the case of project start can write code directly, it can be accessed directly after saving.

For example: We add a method in IndexController getParam, the return parameters entered by the user.

1: let the project started:

image3.png


2: In case where the start of the project, perform coding operation:

image4.png


After encoding is complete, save the log to see control:

image5.png

Compiler will automatically restart. We do not manually restarted.

GetParam access method in your browser:

image6.png


Magic ah. We did not even use Chinese garbled ah! !

Why is this? Since spring boot default encoding is UTF-8 encoded.

In pom.xml we can see:

image7.png



2: The First resul style Code:

Specific code:

image8.png


Browser preview:

image9.png

Three: The project labeled jar and start access

3.1: Project Package

the simplest:

image10.png

Enter the command: clean package

image11.png


If this is the first time packaged, it will be slower. Because the need to download additional jar. Wait patiently

Etc. appear:

image12.png


After the build success, description will be successful.

If you need to enter other packaging commands, then:

Use this option maven duild ...


Check the packaging:

image13.png

Where to find the location of the jar,

image14.png


In this open a command line:

image15.png


Enter the command: java -jar + name just packed

image16.png


We can see that:

image17.png


Yes, you read right. The project began, it turned up. Really up.

In order to determine whether it is up

We visited in the browser:

image18.png


Guess you like

Origin blog.51cto.com/kaigejava/2437692