SpringBoot使用maven指定依赖包的版本(解决示例)
作者:weixin_44953227
我们在使用A依赖的时候,这个依赖有引入了第三方B依赖,这时候我想指定B依赖的版本号,下面个大家分享解决示例,对SpringBoot maven依赖包相关配置方法感兴趣的朋友一起看看吧
前言:我们在使用A依赖的时候,这个依赖有引入了第三方B依赖,这时候我想指定B依赖的版本号
1. 解决示例
我想将 mysql、logback、tomcat
的版本升级到指定版本
只需在 pom.xml
文件的 properties
里面添加如下配置
<properties> <java.version>1.8</java.version> <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> <!--指定springboot依赖的版本号--> <!--将 mysql-connector-java-8.0.22 升级到 mysql-connector-java-8.0.27--> <!--将 logback-classic-1.2.3.jar 升级到 logback-classic-1.2.9.jar--> <mysql.version>8.0.27</mysql.version> <mysql.version.databind>${mysql.version}</mysql.version.databind> <logback.version>1.2.9</logback.version> <logback.version.databind>${logback.version}</logback.version.databind> <!--将 tomcat-embed-core-9.0.39.jar、tomcat-embed-websocket-9.0.39.jar 升级到 9.0.69--> <tomcat.version>9.0.69</tomcat.version> <tomcat.version.databind>${logback.version}</tomcat.version.databind> </properties>
2. 完整pom示例
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.5.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.platform</groupId> <artifactId>biz-api</artifactId> <version>1.2.12</version> <name>biz-api</name> <description>业务api</description> <properties> <java.version>1.8</java.version> <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> <!--指定springboot依赖的版本号--> <!--将 mysql-connector-java-8.0.22 升级到 mysql-connector-java-8.0.27--> <!--将 logback-classic-1.2.3.jar 升级到 logback-classic-1.2.9.jar--> <mysql.version>8.0.27</mysql.version> <mysql.version.databind>${mysql.version}</mysql.version.databind> <logback.version>1.2.9</logback.version> <logback.version.databind>${logback.version}</logback.version.databind> <!--将 tomcat-embed-core-9.0.39.jar、tomcat-embed-websocket-9.0.39.jar 升级到 9.0.69--> <tomcat.version>9.0.69</tomcat.version> <tomcat.version.databind>${logback.version}</tomcat.version.databind> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</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>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.17</version> </dependency> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!--json--> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.83</version> </dependency> <!--sm4算法依赖--> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.4.1</version> </dependency> </dependencies> <build> <plugins> <!-- 将git的commit id打进jar包里面 --> <plugin> <groupId>pl.project13.maven</groupId> <artifactId>git-commit-id-plugin</artifactId> <configuration> <includeOnlyProperties> <includeOnlyProperty>git.commit.id</includeOnlyProperty> </includeOnlyProperties> </configuration> </plugin> </plugins> </build> </project>
到此这篇关于SpringBoot使用maven指定依赖包的版本的文章就介绍到这了,更多相关SpringBoot maven依赖包内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!