使用io.spring.platform时,它会管理各类经过集成测试的依赖版本号。

但有的时候,我们想使用指定的版本号,这个时候就需要去覆盖io.spring.platform的版本号。

前面的文章总结过,使用io.spring.platform有两种方式,一种是继承,一种是导入。

一、先来看继承的方式:

io.spring.platform使用Brussels-SR7版本

<parent>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR7</version>
</parent>

我们想使用阿里的easyexcel框架,2.0.5版本

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.0.5</version>
</dependency>

这个时候就出现了依赖问题,easyexcel 2.0.5版本会依赖poi 3.17版本,而io.spring.platform管理的依赖却是3.15版本。

由于依赖都是io.spring.platform管理的,所以打包时会强制使用poi 3.15版本,这会导致代码执行时找不到对应的新版本class,执行失败。

在继承方式使用io.spring.platform时,解决方法也比较简单,覆盖io.spring.platform对poi的版本号管理即可

<properties>
<poi.version>3.17</poi.version>
</properties>

这个时候在来看依赖关系,发现poi的版本引入变成了3.17

这样就解决了问题。

附上完整pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com</groupId>
<artifactId>springboot-dependency7</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>springboot-dependency7</name>
<url>http://maven.apache.org</url> <parent>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR7</version>
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<poi.version>3.17</poi.version>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.0.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.springboot_dependency7.main.Applicaiton</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

二、再来看import的方式

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

同样引入easyexcel 2.0.5依赖

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.0.5</version>
</dependency>

这个时候poi的版本被强制使用3.15

要覆盖io.spring.platform的版本号需要在pom.xml里dependencyManagement节点io.spring.platform引入的前面加上poi的引入

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

再来看poi的依赖

版本已经变成了3.17,解决问题。

附上完整pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com</groupId>
<artifactId>springboot-dependency8</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>springboot-dependency8</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>Brussels-SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.0.5</version>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.springboot_dependency8.main.Applicaiton</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

io.spring.platform继承方式和import方式更改依赖版本号的问题的更多相关文章

  1. spring-boot-dependencies、spring-boot-starter-parent、io.spring.platform详解

    上一篇文章介绍了springboot依赖版本号管理的几种方式,现在来详细分析一下spring-boot-dependencies.spring-boot-starter-parent.io.sprin ...

  2. springboot依赖的一些配置:spring-boot-dependencies、spring-boot-starter-parent、io.spring.platform

    springboot里会引入很多springboot starter依赖,这些依赖的版本号统一管理,springboot有几种方案可以选择. 一.spring-boot-dependencies 有两 ...

  3. 覆盖io.spring.platform管理的版本号

    使用io.spring.platform时,它会管理各类经过集成测试的依赖版本号.想要覆盖其中某个依赖的版本号个: https://www.cnblogs.com/ld-mars/p/11818252 ...

  4. CSS的导入方式:link与import方式的区别

    在前端开发中,加载CSS样式文件有两种方式:link方式与import方式,它们之间的区别主要有以下几点: 1.兼容性不一样 link是一个HTML标签,所以它不存在兼容性问题,而import方式则具 ...

  5. spring定时任务的几种实现方式

    Spring定时任务的几种实现 近日项目开发中需要执行一些定时任务,比如需要在每天凌晨时候,分析一次前一天的日志信息,借此机会整理了一下定时任务的几种实现方式,由于项目采用spring框架,所以我都将 ...

  6. Spring Boot开启的 2 种方式

    Spring Boot依赖 使用Spring Boot很简单,先添加基础依赖包,有以下两种方式 1. 继承spring-boot-starter-parent项目 <parent> < ...

  7. Elasticsearch学习(3) spring boot整合Elasticsearch的原生方式

    前面我们已经介绍了spring boot整合Elasticsearch的jpa方式,这种方式虽然简便,但是依旧无法解决我们较为复杂的业务,所以原生的实现方式学习能够解决这些问题,而原生的学习方式也是E ...

  8. Spring创建JobDetail的两种方式

    一.Spring创建JobDetail的两种方式 二.整合方式一示例步骤 1.将spring核心jar包.quartz.jar和Spring-context-support.jar导入类路径. 2.编 ...

  9. Spring Boot开启的2种方式

    Spring Boot依赖 使用Spring Boot很简单,先添加基础依赖包,有以下两种方式 1. 继承spring-boot-starter-parent项目 <parent> < ...

随机推荐

  1. 0809NOIP模拟测试赛后总结

    终于有点脸单独建一个随笔写一下考试总结了…… T1一眼组合数学,推了一会儿式子发现恐怕是容斥.突然害怕,于是开始大力dp. 然后骗了70分走人hhh. T2挂了……又读错题了……以为必须相邻,然后就原 ...

  2. angular项目中遇到的问题

    一.angular项目中如何实现路由缓存 需要实现的效果,对请求的数据进行缓存,比如进入文章详情页之后点击返回,不会再调用后台数据接口:而是加载缓存中的数据,如何数据变动的情况下,可使用下拉刷新刷新页 ...

  3. c语言学习笔记 - 指针和字符串

    前面学习了字符串是一种字符数组,又知道了指针变量和数组的关系,这里来看一下指针和字符串的关系. #include <stdio.h> int main(void){ char str = ...

  4. Python学习day25-面向对象之组合,多态和封装

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

  5. utils03_clone远程仓库

    1.Bash here 克隆方式 复制要克隆远程仓库的SSH或者HTTPS 使用Bash here克隆文件 2.使用git同步

  6. IE6下extjs 弹窗不加载内容(无法执行内部js)的解决方案

    //需要导入的文件,这里的路径需要些你自己的路径 <link rel="stylesheet" type="text/css" href="ex ...

  7. BM线性递推

    #include<bits/stdc++.h> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++) #defi ...

  8. XML 映射文件

    MyBatis 的真正强大在于它的映射语句,这是它的魔力所在.由于它的异常强大,映射器的 XML 文件就显得相对简单.如果拿它跟具有相同功能的 JDBC 代码进行对比,你会立即发现省掉了将近 95% ...

  9. CentOS 6.5 FTP安装配置

    安装配置 rpm -q vsftpd #检查是否安装了FTP yum -y install vsftpd #安装FTP chkconfig vsftpd on #设置开机启动 service vsft ...

  10. 在Linux中常用的启动引导工具:grub和lilo

    在Linux和WINDOWS两系统并存时就需要安装GRUB(Grand Unified Bootloader),GRUB被广泛地用于替代lilo,GRUB支持在启动时使用命令行模式,支持md5加密保护 ...