导入时如何定制spring-boot依赖项的版本
来源:互联网 发布:建筑工程预算软件 编辑:程序博客网 时间:2024/05/21 11:24
spring-boot通过maven的依赖管理为我们写好了很多依赖项及其版本,我们可拿来使用。spring-boot文档介绍了两种使用方法,一是继承,二是导入。
通过<parent>继承:
1
2
3
4
5
6
7
<
project
>
<
parent
>
<
groupId
>org.springframework.boot</
groupId
>
<
artifactId
>spring-boot-starter-parent</
artifactId
>
<
version
>1.1.9.RELEASE</
version
>
</
parent
>
</
project
>
或者在<dependencyManagement>中导入:
1
2
3
4
5
6
7
8
9
10
11
<
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版本:
1
2
3
<
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、先建一个过渡性工程,继承后定制依赖项的版本。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<
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、然后导入到自己的工程里。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<
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
>
这样,虽然多建了一个过渡性工程,但定制依赖项版本同继承时一样简单。
阅读全文
0 0
- 导入时如何定制spring-boot依赖项的版本
- 导入时如何定制spring-boot依赖项的版本
- 导入时如何定制spring-boot依赖项的版本
- 导入时如何定制spring-boot依赖项的版本
- 30. 导入时如何定制spring-boot依赖项的版本【转载】【从零开始学Spring Boot】
- 30. 导入时如何定制spring-boot依赖项的版本【转载】【从零开始学Spring Boot】
- (30)导入时如何定制spring-boot依赖项的版本【转载】【从零开始学Spring Boot】
- spring-boot 依赖项的版本 继承 和 导入
- 如何定制 Spring Boot 的 Banner
- spring-boot + storm 依赖的json-simple版本冲突
- 定制Spring Boot的Banner
- spring boot常用的依赖
- spring boot : 定制自己的starter
- Spring Boot:定制自己的starter
- Spring boot 定制banner
- Spring Boot程序的依赖下载耗时
- spring boot 依赖注入
- Spring Boot 依赖注入
- 方法基础概念学习
- 河南省第七届大学生程序设计竞赛 物资调度
- 深度学习模型、概念思维导图分享
- HDU6165-FFF at Valentine
- 关于hibernate在数据库中生成hibernate_sequence表时报错的解决方案
- 导入时如何定制spring-boot依赖项的版本
- 排序小结
- 基于Putty的远程登录操作Linux服务器的一些"套路"
- IEC 60335-1: 2001新标准的变化简介
- 堆和栈的区别(转过无数次的文章)
- Python网络爬虫与信息提取-Day2-requests库(2)
- MultiActionController,PropertiesMethodNameResolver,ParameterMethodNameResolver例子
- KMP小结
- git指令大全