使用Spring Boot很简单,先添加基础依赖包,有如下两种方式spring
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.6.RELEASE</version> </parent>
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.5.6.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencyManagement>
This only works if your Maven project inherits (directly or indirectly) from spring-boot-dependencies. If you have added spring-boot-dependencies in your own dependencyManagement section with <scope>import</scope> you have to redefine the artifact yourself instead of overriding the property.微信
Spring Boot依赖包里面的组件的版本都是和当前Spring Boot绑定的,若是要修改里面组件的版本,只须要添加以下属性覆盖便可,但这种方式只对继承有效,导入的方式无效。编辑器
<properties> <slf4j.version>1.7.25<slf4j.version> </properties>
若是导入的方式要实现版本的升级,达到上面的效果,这样也能够作到,把要升级的组件依赖放到Spring Boot以前。ide
<dependencyManagement> <dependencies> <!-- Override Spring Data release train provided by Spring Boot --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-releasetrain</artifactId> <version>Fowler-SR2</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.5.6.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
Each Spring Boot release is designed and tested against a specific set of third-party dependencies. Overriding versions may cause compatibility issues.spring-boot
须要注意,要修改Spring Boot的依赖组件版本可能会形成不兼容的问题。.net
使用继承Spring Boot时,若是要使用Maven resource filter过滤资源文件时,资源文件里面的占位符为了使${}和Spring Boot区别开来,此时要用@...@包起来,否则无效。另外,@...@占位符在yaml文件编辑器中编译报错,因此使用继承方式有诸多问题,坑要慢慢趟。code
推荐:Spring Boot & Cloud 最强技术教程继承
扫描关注咱们的微信公众号,干货天天更新。教程