io.spring.platform inheritance and import dependence way change the version number

When using io.spring.platform, it will go through all kinds of management integration testing depends on the version number.

But sometimes, we want to use the version number is specified, this time we need to override the version number of io.spring.platform.

Previous article summed up, use io.spring.platform there are two ways, one is inherited, one is imported.

A first look inheritance way:

io.spring.platform use the Brussels-SR7 version

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

We want to use easyexcel Ali framework, version 2.0.5

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

This time there have been dependent problem, easyexcel 2.0.5 version will depend poi 3.17 version, but depends io.spring.platform management is version 3.15.

Since the dependence is io.spring.platform management, it forces the use of poi 3.15 version package, which will lead to a new version of class can not find the corresponding time code execution, execution failed.

 

 

 When using io.spring.platform inheritance, the solution is relatively simple, covering io.spring.platform version of the management of poi to

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

This time dependencies of view, found poi introduced into a version 3.17

 

 

 This would solve the problem.

Accompanied by a full 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>

 

Second, look at the way 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>

Also introduced easyexcel 2.0.5 dependent

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

This time poi versions are forced to use 3.15

 

 

 To override the previous version io.spring.platform need dependencyManagement io.spring.platform introduced nodes in pom.xml plus the introduction of poi

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>3.17</version>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>artifactId</poi-OOXML>
      <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>

Let's look at poi dependence

 

 Version 3.17 has become, to solve the problem.

Accompanied by a full 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.then </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>

 

Guess you like

Origin www.cnblogs.com/ld-mars/p/11818252.html