如何解决IntelliJ SBT随附库中的版本冲突

如何解决IntelliJ SBT随附库中的版本冲突

问题描述:

我在项目中使用了 ScalaTest 2.2.1 ,但是我使用的某些依赖项引入了 ScalaTest 1.9.2 .在SBT中,这不会引起任何问题.它会编译并运行所有测试.

I am using ScalaTest 2.2.1 in my project but some dependency I use brings in ScalaTest 1.9.2. In SBT, this causes no proble. It compiles and runs all tests.

在IntelliJ中,测试显示 in 并带有无法解析符号输入",尽管它仍可以编译.但是测试跑步者死于"

In IntelliJ, the test show the in with "cannot resolve symbol in" although it still compiles. Hoever the test runner dies with"

An exception or error caused a run to abort: org.scalatest.FlatSpecLike$$anonfun$1$$anon$2 cannot be cast to org.scalatest.words.ResultOfStringPassedToVerb

如果我从外部库中手动删除 ScalaTest 1.9.2 ,所有操作都将再次生效,但是当然,下一次刷新项目时,我将回到第一个方框.

If I manually remove ScalaTest 1.9.2 from the External Libraries, all works again, but of course the next time the project refreshes, I'm back to square one.

我需要设置一些用于解决IntelliJ中的冲突的配置吗?还是这是IntelliJ的错误?

Is there some configuration for conflict resolution in IntelliJ that I need to set or is this an IntelliJ bug?

SBT在内部将其 conflictManager 默认设置为 latestRevision .但是,当intellij运行自己的SBT版本时,似乎没有设置相同的默认值.似乎有效的方法是在SBT配置中显式设置冲突管理器:

SBT, internally, defaults its conflictManager to latestRevision. However, when intellij runs its own version of the SBT build, it doesn't seem to set the same default. What seems to work is to explicitly set the conflict manager in the SBT config:

conflictManager := ConflictManager.latestRevision

在我的场景中,Intellij仍会将测试的某些方面标为无法解析符号",但是编译,测试运行都不再失败

Intellij will still color code certain aspects of the test in my scenario as "Cannot resolve symbol", but neither compile, not test run are failing anymore