导入时如何定制spring-boot依赖项的版本
2016-01-20 15:06
856 查看
http://www.tuicool.com/articles/RJJvMj3
时间 2015-06-22 13:32:00 博客园-原创精华区
原文 http://www.cnblogs.com/yang-wu/p/4593194.html
主题 Java
spring-boot通过maven的依赖管理为我们写好了很多依赖项及其版本,我们可拿来使用。spring-boot文档介绍了两种使用方法,一是继承,二是导入。
通过<parent>继承:
或者在<dependencyManagement>中导入:
此外,在其 文档 里说到,继承时可简单地通过属性定制依赖项版本。比如,改为使用较新的spring-4.1.6.RELEASE版本:
不过,此法只对继承有效,导入无效。以下摘自其文档说明:
导入时有没有较简单的方法呢?我们可先继承后导入!
1、先建一个过渡性工程,继承后定制依赖项的版本。
2、然后导入到自己的工程里。
这样,虽然多建了一个过渡性工程,但定制依赖项版本同继承时一样简单。
时间 2015-06-22 13:32:00 博客园-原创精华区
原文 http://www.cnblogs.com/yang-wu/p/4593194.html
主题 Java
spring-boot通过maven的依赖管理为我们写好了很多依赖项及其版本,我们可拿来使用。spring-boot文档介绍了两种使用方法,一是继承,二是导入。
通过<parent>继承:
<project> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.1.9.RELEASE</version> </parent> </project>
或者在<dependencyManagement>中导入:
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.1.9.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
此外,在其 文档 里说到,继承时可简单地通过属性定制依赖项版本。比如,改为使用较新的spring-4.1.6.RELEASE版本:
<properties> <spring.version>4.1.6.RELEASE<spring.version> </properties>
不过,此法只对继承有效,导入无效。以下摘自其文档说明:
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.
导入时有没有较简单的方法呢?我们可先继承后导入!
1、先建一个过渡性工程,继承后定制依赖项的版本。
<project> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.1.9.RELEASE</version> </parent> <groupId>mycomp</groupId> <artifactId>myproject-spring-boot-bom</artifactId> <version>1.1.9</version> <packaging>pom</packaging> <properties> <spring.version>4.1.6.RELEASE</spring.version> </properties> </project>
2、然后导入到自己的工程里。
<project> <modelVersion>4.0.0</modelVersion> <groupId>mycomp</groupId> <artifactId>myproject</artifactId> <version>0.0.1-SNAPSHOT</version> <dependencyManagement> <dependencies> <dependency> <groupId>mycomp</groupId> <artifactId>myproject-spring-boot-bom</artifactId> <version>1.1.9</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> </project>
这样,虽然多建了一个过渡性工程,但定制依赖项版本同继承时一样简单。
相关文章推荐
- 深入浅出设计模式(九):12.装饰模式(Decorator) 13.桥模式(Bridge)14.策略模式(Strategy)
- spring---定时任务(quartz定时器)
- 如何使用 Java 构建微服务?
- 如何使用 Java 构建微服务?
- java基础之字符串转日期
- spring InitializingBean接口
- 怎么在MyEclipse编辑区左边显示行号
- java获取本机ip和mac地址
- 深入Java集合学习系列:HashMap的实现原理
- Leetcode@jump Game
- Java_并发线程_CompletionService
- Java实现数据库连接池简易教程
- Java正则表达式的语法与示例
- java语言概述
- Eclipse中创建Maven web项目
- JAVA虚拟机的生命周期
- 谈谈Java中try-catch-finally中的return语句
- Eclipse中安装Subversive (Subversion的对应模块)
- Leetcode @ Gas Station
- java.lang.UnsatisfiedLinkError: Can't load IA 64-bit .dll on a AMD 64-bit platform