此文章转载地址:http://www.tuicool.com/articles/RJJvMj3 请注重作者的版权。

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>

这样,虽然多建了一个过渡性工程,但定制依赖项版本同继承时一样简单。

Spring Boot 系列博客】

49. spring boot日志升级篇—理论【从零开始学Spring Boot】

48. spring boot单元测试restfull API【从零开始学Spring Boot】

47. Spring Boot发送邮件【从零开始学Spring Boot】

46. Spring Boot中使用AOP统一处理Web请求日志

45. Spring Boot MyBatis连接Mysql数据库【从零开始学Spring Boot】

44. Spring Boot日志记录SLF4J【从零开始学Spring Boot】

43. Spring Boot动态数据源(多数据源自动切换)【从零开始学Spring Boot】

42. Spring Boot多数据源【从零开始学Spring Boot】

41. Spring Boot 使用Java代码创建Bean并注册到Spring中【从零开始学Spring Boot】

40. springboot + devtools(热部署)【从零开始学Spring Boot】

39.4 Spring Boot Shiro权限管理【从零开始学Spring Boot】

39.3 Spring Boot Shiro权限管理【从零开始学Spring Boot】

39.2. Spring Boot Shiro权限管理【从零开始学Spring Boot】

39.1 Spring Boot Shiro权限管理【从零开始学Spring Boot】

38 Spring Boot分布式Session状态保存Redis【从零开始学Spring Boot】

37 Spring Boot集成EHCache实现缓存机制【从零开始学Spring Boot】

36 Spring Boot Cache理论篇【从零开始学Spring Boot】

35 Spring Boot集成Redis实现缓存机制【从零开始学Spring Boot】

34Spring Boot的启动器Starter详解【从零开始学Spring Boot】

33 Spring Boot 监控和管理生产环境【从零开始学Spring Boot】

32 Spring Boot使用@SpringBootApplication注解【从零开始学Spring Boot】

31 Spring Boot导入XML配置【从零开始学Spring Boot】

30 导入时如何定制spring-boot依赖项的版本【转载】【从零开始学Spring Boot】

更多查看博客: http://412887952-qq-com.iteye.com/

转载于:https://www.cnblogs.com/hehehaha/p/6147113.html

(30)导入时如何定制spring-boot依赖项的版本【转载】【从零开始学Spring Boot】...相关推荐

  1. 54. spring boot日志升级篇—logback【从零开始学Spring Boot】

    在<44. Spring Boot日志记录SLF4J>章节中有关相关的介绍,这里我们在深入的了解下logback框架. 为什么要使用logback ? --在开发中不建议使用System. ...

  2. 17、Spring Boot普通类调用bean【从零开始学Spring Boot】

    转载:http://blog.csdn.net/linxingliang/article/details/52013017 我们知道如果我们要在一个类使用spring提供的bean对象,我们需要把这个 ...

  3. 1. spring boot起步之Hello World【从零开始学Spring Boot】

    转载:http://blog.csdn.net/linxingliang/article/details/51582286 1.1 介绍 自从structs2出现上次的漏洞以后,对spring的关注度 ...

  4. (28)SpringBoot启动时的Banner设置【从零开始学Spring Boot】

    对于使用过Spring Boot的开发者来说,程序启动的时候输出的由字符组成的Spring符号并不陌生.这个是Spring Boot为自己设计的Banner: 1.    .   ____       ...

  5. (39.3) Spring Boot Shiro权限管理【从零开始学Spring Boot】

    在学习此小节之前您可能还需要学习: (39.1) Spring Boot Shiro权限管理[从零开始学Spring Boot] http://412887952-qq-com.iteye.com/b ...

  6. (10)Spring Boot修改端口号【从零开始学Spring Boot】

    Spring boot 默认端口是8080,如果想要进行更改的话,只需要修改applicatoin.properties文件,在配置文件中加入: server.port=9090 常用配置: #### ...

  7. 78. Spring Boot完美使用FastJson解析JSON数据【从零开始学Spring Boot】

    [原创文章,转载请注明出处] 个人使用比较习惯的json框架是fastjson,所以spring boot默认的json使用起来就很陌生了,所以很自然我就想我能不能使用fastjson进行json解析 ...

  8. 60. Spring Boot写后感【从零开始学Spring Boot】

    从2016年4月15日到2016年7月20日经历长达3个月的时间,[从零开始学习Spring Boot]系列就要告一段落了.国内的各种资源都比较乱或者是copy 来copy去的,错了也不加以修正下,导 ...

  9. 70.打印所有Spring boot载入的bean【从零开始学Spring Boot】

    [从零开始学习Spirng Boot-常见异常汇总] 问题的提出: 我们在开发过程当中,我们可能会碰到这样的问题:No qualifying bean  就是我们定义的bean无法进行注入,那到底是什 ...

最新文章

  1. linux日志系统的实现,一个同步日志系统的简单实现 log for c (linux 平台)
  2. 使用NDK过程中出现“Unresolved inclusion jni.h”
  3. 50. Leetcode 105. 从前序与中序遍历序列构造二叉树 (二叉树-二叉树构建)
  4. linux read01,Linux内置命令之read
  5. C++内存分配与对象构造的分离
  6. Kubernetes存储卷的使用
  7. 成中集团线下IDC迁移上云
  8. 从项目实际问题引发的思考
  9. 实时体积云渲染(地平线):二.Perlin噪声和Worley噪声
  10. 求数组中最小的k个数
  11. International Journal of Rock Mechanics and Mining Sciences (Vol 124-12月期最新研究译文)
  12. 在办公室说话要注意哪些?
  13. layui省市区联动选择的实现
  14. 海思芯片固件修改工具_魔百盒九联代工M301H海思Hi3798MV310芯片红外蓝牙语音遥控免拆卡刷固件及刷机教程202009版...
  15. Web of Science的正确打开方式
  16. switchport nonegotiate
  17. 会员营销中,数字会员模式如何打造差异化会员服务
  18. 全球与中国工业级氟化氢铵市场现状及未来发展趋势2022
  19. Latex beamer 制作 PPT
  20. python中tile的用法_Python numpy.tile函数方法的使用

热门文章

  1. LeetCode 报错解决 heap-buffer-overflow Heap-use-after-free Stack-buffer-overflow Global-buffer-overflow
  2. 解决UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte问题
  3. php t double arrow,关于php:php – 语法错误,意外T_DOUBLE_ARROW
  4. Linux中的输入输出管理
  5. Azkaban入门(启动一个Simple Example)
  6. python删除重复值所在的行数_使用python读取txt文件的内容,并删除重复的行数方法...
  7. 一篇复习一下Spring和SpringMVC基本概念
  8. 一致代价搜索_谷歌工程师发布最新技术ScaNN:可实现高效的向量相似性搜索
  9. 原来腾讯面试题也不难,面试官:给我说一下你理解的分布式架构?
  10. android好还是windows好,收银机操作系统哪种好?安卓系统与Windows系统区别?