使用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. index方法用于数据集的强制索引操作

    index方法为3.2.3版本新增,用于数据集的强制索引操作,例如: $Model->index('user')->select(); 对查询强制使用user索引,user必须是数据表实际 ...

  2. light oj 1098 数学规律

    #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> ...

  3. 表单下拉框select

    <!DOCTYPE html> <html lang="zh"> <head> <title></title> < ...

  4. 爬虫(二)建立代理ip池

    之前我们说网站反爬虫的一个常用方法是检测ip,限制访问频率.所以我们要通过设置代理ip的办法绕过这个限制.有不少提供免费代理ip的网站,像https://www.xicidaili.com/nt/,我 ...

  5. Python学习之--数据基础

    对于Python来说,一切皆对象.包括数字.字符串.列表等,对象是由类来创建的,那对象的一个优点就是可以使用其创建类中所定义的各种方法. 查看对象/方法 1)可以在命令行中直接查看,如下: >& ...

  6. C语言开发系列-二进制

    n位二进制的取值范围 -2的n-1次方 ~ 2的n-1次方-1 输出一个整数的二进制的存储形式 #include <stdio.h> // 输出一个整数的二进制的存储形式 void put ...

  7. mybatis配合pagehelper分页助手查询

    Maven: 参考: springBoot2.x整合pagehelper5.1.2:https://blog.csdn.net/Carlson_Chis/article/details/8563748 ...

  8. 8种nosql数据库对比

    1. CouchDB 所用语言: Erlang 特点:DB一致性,易于使用 使用许可: Apache 协议: HTTP/REST 双向数据复制, 持续进行或临时处理, 处理时带冲突检查, 因此,采用的 ...

  9. nowcoder牛客wannafly挑战赛20

    A---染色 签到题,设最终颜色为x,一次操作就需要把一个不是x的点变为x,所以最终颜色为x时需要操作 总结点个数-颜色为x的节点个数,然后枚举所有颜色就行了 #include <iostrea ...

  10. gitlab不支持mysql,这就是我学习PostgreSQL的原因

    Gitlab 官方宣布,将从 12.1 版本开始不再支持 MySQL 数据库.早在 2017年7月,Gitlab 就计划将弃用对 MySQL 的支持.而目前这个决定将从 12.1 版本开始. 编辑注: ...