Tag: Cal Pack Access Environment complete star boot not app
First, install the Springboot plug-in
Installation process requires networking download plug-in, is an online installation, please wait for the installation to complete, after the download installation is complete, you need to restart eclipse
Second, create the Spring boot project
As shown in new-other-spring boot-spring Starter Project, if the relevant option is not found, the previous step of the Spring Boot plugin was not successfully installed
Click Next, fill in the project name as shown and select Java version
The next step, as shown here, is to tick the Web options below the Web and click Finish to finish, so the project is created.
Third, run the Spring boot project
Let's start by writing a simple example, such as modifying the system default class, located below/src/main/java
-----------------------originally generated by default is as follows
Package Com.example.demo;import Org.springframework.boot.springapplication;import Org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplicationpublic class springbootdemo1application {public static void main (string[] args) {Springapplication.run ( Springbootdemo1application.class, args);}}
-----------------------Modify the following to implement a function like Hello world!
Package Com.example.demo;import Org.springframework.boot.springapplication;import Org.springframework.boot.autoconfigure.springbootapplication;import Org.springframework.web.bind.annotation.requestmapping;import Org.springframework.web.bind.annotation.RestController, @RestController @springbootapplicationpublic class springbootdemo1application {@RequestMapping ("/") public String Hello () { return "Hello springboot!"; } public static void Main (string[] args) {Springapplication.run (springbootdemo1application.class, args);}}
After the project has been modified, we then run the project:
3.1, the first mode of operation
Directly run the main method in Springbootdemo1application.class, right-click Run as Java application, as shown in
The console tells us that the program has been started, and the port is 8080, then we see the effect through the browser, the browser input localhost:8080 effect is as follows
3.2, the second mode of operation
Right-Select the project run As→maven build, as shown in step 1-2-3, and then click Run to start the Spring boot project
The result of the operation is the same as shown in
3.3. The third mode of operation
Packaged run, run As→maven build as shown in command clean package
Click Run To view the console panel the following path has generated the jar
Go to the corresponding path to find the jar, I copy it here to D, and then into the Windows DOS command window, as shown in
The end result is
You can see that the result is the same as in other ways, when we close eclipse, the service is still accessible, put the jar into a Java environment server to execute Java-jar Xxx.jar can start the service, As for the direct use of export exports jar is not the same reason, we can test it by ourselves.
Eclipse creates the first spring boot project