Use spring boot to quickly build a Restful-style microservices
No spring configuration files, pure Java engineering, can be quickly released, debug projects
1. Create a MAVEN project
2. Import the following configuration
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >< Modelversion>4.0.0</modelversion><groupid>com.iraid.test</groupid><artifactid> Spring-boot</artifactid><version>0.0.1-snapshot</version><parent><groupid> org.springframework.boot</groupid><artifactid>spring-boot-starter-parent</artifactid>< Version>1.3.5.release</version></parent><dependencies><dependency><groupid> org.springframework.boot</groupid><artifactid>spring-boot-starter-web</artifactid></ Dependency></dependencies></project>
3. Create Restcontroller
@RestController @enableautoconfigurationpublic class Greetcontroller {@Autowiredprivate userservice userservice; @RequestMapping ("/greet") User greet () {return userservice.getuser (1L); }}
4. Create the startup class, this can be omitted, directly put the Mian method in the other controller class run can
Package Com.iraid.test.boot;import Org.springframework.boot.springapplication;import Org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplicationpublic class Application { public static void Main (string[] args) {Springapplication.run (application.class, args); }}
5. Packaging
MVN Install
6. Running
Java-jar Spring-boot-0.0.1-snapshot.jar
7. Testing
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/80/50/wKiom1c9miOCa2UZAAA62ceX63U041.png "title=" Spring.png "alt=" Wkiom1c9mioca2uzaaa62cex63u041.png "/>
This article is from the "Wandering Footsteps" blog, please make sure to keep this source http://now51jq.blog.51cto.com/3474143/1775149
Spring boot quickly builds a Restful-style micro-service