Spring Boot integrates a lot of things together, and when you build a MAVEN project, you just need to introduce a few dependencies to build the project.
1. Build MAVEN Project Structure
2. The introduction of spring boot dependency directly to the official website to find it, there are examples of
3.pom.xml Import Dependency Package, the beginning of the version of the 1.5.10 do not know why the main method started when Tomcat could not start, and then changed the version can be
<Dependencies>        <Dependency>            <groupId>Org.springframework.boot</groupId>            <Artifactid>Spring-boot-starter-web</Artifactid>            <version>1.5.7.RELEASE</version>        </Dependency>    </Dependencies>
4.main method starts the spring boot start class with @SpringBootApplication annotations
 Package Di.bao; Import org.springframework.boot.SpringApplication; Import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication  Public class Firstapp {    publicstaticvoid  main (string[] args) {        Springapplication.run (Firstapp. class , args);}    }
5.tomcat can be accessed directly after booting, direct access to port 8080 will appear error page, write a Controller, start with @controller annotations, access to 8080/nihao, the page appears the method return value.
 package   Di.bao;  import   Org.springframework.stereotype.Controller;  import   org.springframework.web.bind.annotation.GetMapping;  import   org.springframework.web.bind.annotation.ResponseBody; @Controller  public  class    Nicontroller {@GetMapping ( "/nihai"  public   String hello () { return "Shi Jie ni hao!"    ; }}
6.rest interface, return JOSN format string: Create a class, write controller, Access HTTP://LOCALHOST:8080/STUDENT/1, page: {"name": "Zhangsan", "id": 1}
 PackageDi.bao; Public classStudent {PrivateString name; Private intID;  PublicStudent () {} PublicString GetName () {returnname; }     Public voidsetName (String name) { This. Name =name; }     Public intgetId () {returnID; }     Public voidSetId (intID) { This. ID =ID; }        }
 PackageDi.bao;ImportOrg.springframework.http.MediaType;ImportOrg.springframework.stereotype.Controller;Importorg.springframework.web.bind.annotation.PathVariable;Importorg.springframework.web.bind.annotation.RequestMapping;ImportOrg.springframework.web.bind.annotation.RequestMethod;Importorg.springframework.web.bind.annotation.ResponseBody; @Controller Public classJosncontroller {/*** Value Path method Access methods produces output what *@paramID *@return     */@RequestMapping (Value= "/student/{id}", method =Requestmethod.get, produces=mediatype.application_json_value) @ResponseBody PublicStudent Hello (@PathVariableintID) {Student Student=NewStudent ();        Student.setid (id);; Student.setname ("Zhangsan"); returnstudent; }}
Note: You must first close the last boot before using the main method again, otherwise the port occupancy appears java.net.BindException:Address already in Use:bind exception.
Command line: netstat-ano|findstr "8080"
Command line: Enter tasklist to see which process is 11000
Win7 in the Task manager, the use of port-occupied programs can be turned off.
Because the system changed WIN10,WIN10 task Manager a bit different, find a half-day also did not find this process, simply the Java related to all turned off, the result is useless,
It was later discovered that there was a Java-related application under Eclipse, and that it could be restarted properly by turning it off.
Spring_boot Primer (1)