1.创建独立的Spring应用程序. 2.嵌入tomcat,Jetty或者Undertow,无需部署war文件; 3.允许通过Maven来获取starter; 4.尽可能的自动配置Spring. 5.提供生产就绪型功能,如指标,健康检查和外部配置. 6.绝对没有代码生成,对xml没有要求配置.
下面创建一个SpringBoot入门项目:
1.pom.xml
<!-- AOP --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <!-- web开发包 --> <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>
2.代码:
//@SpringBootApplication @Controller //启动spring boot自动装配. @EnableAutoConfiguration public class DemoApplication { @RequestMapping("/test") @ResponseBody public Map<String,Object> test(){ Map<String,Object> map = new HashMap<String,Object>(); map.put("key","value"); map.put("key2","value"); return map; } public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }