英文:
gradle - unexplainable dependency version coming
问题
我有一个使用Spring Boot 2.6.1的应用程序,我在测试中使用Selenium。
我使用的是selenium-java
版本4.6.0
。
testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.6.0'
但是,被拉取的传递依赖关系都是旧版本(主要是3.141.59),这导致在运行时出现一些问题,例如找不到类等:
我可以手动覆盖所有这些依赖关系,但这似乎不是正确的方式。
不管怎样,这些版本是从哪里来的呢?我没有在任何地方定义它们,所以我希望拉取https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java/4.6.0 中显示的所有版本。
英文:
I have a Spring Boot 2.6.1 application for which I use Selenium during my tests.
I am using selenium-java
4.6.0
testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.6.0'
but the transitive dependencies that are pulled are all older versions (mostly 3.141.59), which leads to some issue at runtime, with classes not found etc :
I can override all these dependencies manually, but that doesn't look like the right way..
anyway, where are these versions coming from ? I am not defining them anywhere, so I would expect all the versions showed in https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java/4.6.0 to be pulled.
答案1
得分: 1
Spring Boot 依赖管理又一次让我困惑,它大部分时间非常有用,但有时像这里一样令人困惑...
如在 Spring Boot 2.6 文档中所述,Selenium 由 BOM(我之前不知道)管理,令人惊讶的是 v3.141.59
在那里定义 - 所以它来自那里,而我没有在任何地方定义它。
所以解决方案非常简单:我们只需在 Gradle 构建文件中覆盖版本
ext['selenium.version'] = '4.6.0'
dependencies {
testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java'
...
}
然后所有“正确”的依赖版本现在都会生效。
英文:
I again got tricked by Spring Boot dependency management, which is most of the time super useful, but sometimes confusing like here...
As documented in Spring boot 2.6 , Selenium is managed by the BOM (I was not aware of this), and what a surprise : v3.141.59
is defined there - so this is where it's coming from, without me defining it anywhere.
So the solution is quite simple : we simply need to override the version in the gradle build file
ext['selenium.version'] = '4.6.0'
dependencies {
testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java'
...
}
and all the "right" dependencies versions are now coming.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论