如何从spring-boot-starter-parent排除特定依赖项 [英] How to exclude specific dependencies from spring-boot-starter-parent

查看:1787
本文介绍了如何从spring-boot-starter-parent排除特定依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用旧版Spring应用程序,并且想要迁移到Spring Boot.我的意图是使用spring-boot-starter-data-jpa.因此,我在pom.xml(管理所有spring-boot-dependencies)中添加了以下部分:

I am using a legacy Spring application and want to migrate to Spring Boot. My intention is to use the spring-boot-starter-data-jpa. For this reason I have added following section in pom.xml (which manages all spring-boot-dependencies):

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
</parent>

但是这搞砸了我需要暂时保留的某些依赖项.我目前正在使用Selenium依赖项(版本2.53.0;从另一个项目中过渡添加),但是spring-boot正在获取3.9.1的依赖项.

But this is screwing up certain dependencies which I need to retain for time being. I am currently using Selenium dependencies (version 2.53.0; added transitively from another project) but spring-boot is fetching dependencies of 3.9.1.

我想排除3.9.1依赖项,但exclusion过滤器无法按预期工作.

I want to exclude 3.9.1 dependencies but the exclusion filter is not working as expected.

总结一下,我想使用spring-boot-starter-parentspring-boot-starter-data-jpa,而不要使用spring-boot-dependencies中的托管selenium-java.

Just to summarize, I want to use spring-boot-starter-parent and spring-boot-starter-data-jpa but not the managed selenium-java from spring-boot-dependencies.

感谢这方面的帮助.

推荐答案

而不是弄乱<excludes>,然后尝试找出需要再次包含的内容(在找出要排除的内容之后).只需按照此处的说明覆盖版本Spring Boot参考指南.

Instead of messing around with <excludes> and then try to figure out what you need to include again (after figuring out what you excluded). Just override the version as explained here in the Spring Boot Reference Guide.

假设您使用spring-boot-starter-parent作为父级,只需在<properties>部分中添加<selenium.version>即可指定所需的版本.

Assuming you are using the spring-boot-starter-parent as the parent you can just add a <selenium.version> to your <properties> section to specify which version you want.

<properties>
  <selenium.version>2.53.0</selenium.version>
</properties>

这将使Spring Boot使用所需的版本.

This will make Spring Boot use the version you want.

这篇关于如何从spring-boot-starter-parent排除特定依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆