在了解到Spring Boot之前,在构建Spring工程的时候,你需要关注很多,比如项目中需要用到SpringMVC H2 Thymeleaf Jpa Jackson Log4j等等,你必须考虑他们使用什么版本,保证不冲突才能让它顺利的跑起来,很麻烦吧。。。恭喜你,你接触到了Spring Boot,这些问题他都给你解决了,你只需要在创建工程的时候使用Spring Boot 提供的起步依赖,联网自动下载,它就给你全部解决。
Spring Boot提供了很多的起步依赖(可以在http://start.spring.io/进行查询),例如:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<parent>指定了当前项目的pom继承了spring-boot-starter-parent,因为依赖的传递性,所以会带进来很多依赖
当在你的项目的POM文件中增加了上面这段配置,那么恭喜你,你的WEB应用框架已经搭建好了,只需要书写的一个SpringMVC的Controller,你就可以启动并验证你的WEB应用了。
同样使用了起步依赖spring-boot-starter-web,所以同样会得到它的所有依赖,比如:
注:可以在http://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web去下载pom文件详细查看其内容
起步依赖可以帮助你专注于应用程序需要的功能,而非提供该功能的具体库和版本。