Previous Chapter Articles
http://fuaotech.iteye.com/admin/blogs/2292707
We have written a separate startup program for our own microservices to complete the release of microservices. If you think that each project needs components to write this release service, you can use springboot to help us complete the release and let the team Service-focused development
what is springboot
Design demo
After referring to the official materials of various parties and the masterpieces of other website development colleagues, I integrated it myself
First open http://start.spring.io/
The official is also very user-friendly to help me get started as quickly as possible
He provides a basic interface for us, and also lists many components below for different users to choose the business framework you need to guide
If you want to demonstrate, choose the web framework with embedded tomcat, (personally prefer the embedded jetty, but it is not listed above)
Click Generate project to download the configured project (mainly pom.xml)
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
add a class
package com.example;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class DemoController {
@ResponseBody
@RequestMapping(value = "/hello")
String home() {
return "Hello World!";
}
}
Run the default startup class DemoApplication.java
Access http://localhost:8080/hello success
Another important part is the package release
springboot needs to introduce its own build plugin when building
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Still the old way
cd root directory
mvn package
cd target
java -jar xxxx.jar
refer to
http://www.infoq.com/cn/articles/microframeworks1-spring-boot/
http://www.cnblogs.com/skyblog/p/5127690.html