系统要求:
jdk7+(推荐jdk8)
maven 3
eclipse或其他编辑器
用eclipse创建一个maven项目(quick-start).
编写pom.xml
<?xml version=”1.0” encoding=”UTF-8”?>
创建source folder, src/main/java( 如有则忽略)
创建Example.java, 内容如下:
import org.springframework.boot.;
import org.springframework.boot.autoconfigure.;
import org.springframework.stereotype.;
import org.springframework.web.bind.annotation.;
@RestController
@EnableAutoConfiguration
public class Example {
@RequestMapping(“/“)
String home() {
return “Hello World!”;
}
public static void main(String\[\] args) throws Exception {
SpringApplication.run(Example.class, args);
}
}
注意项目依赖的jre选择jre7或jre8.
项目目录结构如下:
运行Example的main方法,输出如下:
浏览器打开http://localhost:8080, 页面内容输出 “Hello World!”
本文实例参考 《spring-boot-reference-guide》一文