Spring Boot是一个微框架。
来源:是由Pivotal团队开发。
设计目的:为了简化Spring的初始配置过程以及开发步骤。
Spring Boot开发支持Spring注解开发,支持@Controller、@RequestMapping ……
第一步,配置POM
<?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.lingluo</groupId>
<artifactId>SpringBoot</artifactId>
<version>1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
第二步,写一个程序入口。
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@EnableAutoConfiguration
@Controller
public class Application extends SpringBootServletInitializer {
@RequestMapping("/")
public String hello(){
return "Hello Spring Boot";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
第三步,运行程序,并访问http://localhost:8080
这样,一个简单完整的web服务器就完成了。
当然Spring Boot也可以直接打包成jar文件。
运行mvn install 生成一个*.jar文件,在命令行执行java -jar *****.jar
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。