springboot的宗旨是习惯大于配置,因此spring里面大量使用了默认的配置来简化spring的配置。spring Boot的主要优势:java
- 为全部Spring开发者更快的入门
- 开箱即用,提供各类默认配置来简化项目配置
- 内嵌式容器简化Web项目
- 没有冗余代码生成和XML配置的要求
开发环境java8,maven,ideaweb
<!-- Inherit defaults from Spring Boot --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.0.RELEASE</version> </parent> <!-- Add typical dependencies for a web application --> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <!-- Package as an executable jar --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
@RestController @EnableAutoConfiguration public class HelloWorld { @RequestMapping("/hello") public String index() { return "Hello World"; } public static void main(String[] args) throws Exception { SpringApplication.run(HelloWorld.class, args); } }