为什么我在 Spring 引导 pom.xml 文件中有此警告? "Overriding managed version 1.5.9 for mariadb-java-client"
Why I have this warning in a Spring Boot pom.xml file? "Overriding managed version 1.5.9 for mariadb-java-client"
我很长时间没有使用 Spring,我有以下疑问。
我有这个 pom.xml 文件与 Spring Boot 项目相关:
<?xml version="1.0" encoding="UTF-8"?>
<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.springboot</groupId>
<artifactId>excel-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Excel API with Spring Boot</name>
<description>Spring Boot - working with Excel API</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-data</artifactId>
</dependency>
<!-- Start of excel dependencies -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
<!-- End of excel dependencies -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- Start DB connectivity dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.5.7</version>
</dependency>
<!-- End DB connectivity dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
我添加了与 Maria DB 数据库连接相关的最后一个依赖项部分,这些行:
<!-- Start DB connectivity dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.5.7</version>
</dependency>
<!-- End DB connectivity dependencies -->
在最后一个依赖项(Maria DB 客户端)上,它给我以下警告消息:
Overriding managed version 1.5.9 for mariadb-java-client
这条消息的确切含义是什么?在我看来,在某种程度上我应该已经有了这个客户端的更新版本(由 Spring 提供)。但是哪里?我以前从未导入过此依赖项,为什么要导入它?
还是我遗漏了什么?
这是因为您的项目将以某种方式扩展 POM spring-boot-dependencies
through extending the parent POM spring-boot-starter-parent
. And inside spring-boot-dependencies
, it defines the version of many dependencies in <dependencyManagement>
which the version of mariadb-java-client
is 1.5.9。
dependency management的目的是用来集中所有依赖项的相关信息。在这种情况下,它为一组库定义了一个默认版本,这样如果一个 children POM 想要包含这些库,它不需要在它们的 pom.xml
中为它们指定版本,因为它是已在 parent 的 <dependencyManagement>
中定义。
因此,在 children 项目的 pom.xml
中,我们可以简单地定义
<dependency>
<groupId>org.foo.bar</groupId>
<artifactId>foo-bar</artifactId>
</dependency>
而不是
<dependency>
<groupId>org.foo.bar</groupId>
<artifactId>foo-bar</artifactId>
<version>1.3.56</version>
</dependency>
它允许扩展此 parent pom 的所有项目将具有一致的依赖项版本。
因此,如果您在 children pom 中指定的依赖项版本与 <dependencyManagement>
中定义的不同,它会给您以下警告:
Overriding managed version X.Y.Z for foo-bar
我很长时间没有使用 Spring,我有以下疑问。
我有这个 pom.xml 文件与 Spring Boot 项目相关:
<?xml version="1.0" encoding="UTF-8"?>
<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.springboot</groupId>
<artifactId>excel-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Excel API with Spring Boot</name>
<description>Spring Boot - working with Excel API</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-data</artifactId>
</dependency>
<!-- Start of excel dependencies -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
<!-- End of excel dependencies -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- Start DB connectivity dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.5.7</version>
</dependency>
<!-- End DB connectivity dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
我添加了与 Maria DB 数据库连接相关的最后一个依赖项部分,这些行:
<!-- Start DB connectivity dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.5.7</version>
</dependency>
<!-- End DB connectivity dependencies -->
在最后一个依赖项(Maria DB 客户端)上,它给我以下警告消息:
Overriding managed version 1.5.9 for mariadb-java-client
这条消息的确切含义是什么?在我看来,在某种程度上我应该已经有了这个客户端的更新版本(由 Spring 提供)。但是哪里?我以前从未导入过此依赖项,为什么要导入它?
还是我遗漏了什么?
这是因为您的项目将以某种方式扩展 POM spring-boot-dependencies
through extending the parent POM spring-boot-starter-parent
. And inside spring-boot-dependencies
, it defines the version of many dependencies in <dependencyManagement>
which the version of mariadb-java-client
is 1.5.9。
dependency management的目的是用来集中所有依赖项的相关信息。在这种情况下,它为一组库定义了一个默认版本,这样如果一个 children POM 想要包含这些库,它不需要在它们的 pom.xml
中为它们指定版本,因为它是已在 parent 的 <dependencyManagement>
中定义。
因此,在 children 项目的 pom.xml
中,我们可以简单地定义
<dependency>
<groupId>org.foo.bar</groupId>
<artifactId>foo-bar</artifactId>
</dependency>
而不是
<dependency>
<groupId>org.foo.bar</groupId>
<artifactId>foo-bar</artifactId>
<version>1.3.56</version>
</dependency>
它允许扩展此 parent pom 的所有项目将具有一致的依赖项版本。
因此,如果您在 children pom 中指定的依赖项版本与 <dependencyManagement>
中定义的不同,它会给您以下警告:
Overriding managed version X.Y.Z for foo-bar