【发布时间】:2017-03-22 15:21:24
【问题描述】:
我想为 Java8 使用最新的 assertj-core(例如在可选项上断言)。 我使用 spring-boot-starter-test 1.4.1,它带有预先配置的 assertj 2.5.0。
我不能使用 spring boot 父 pom。
如何设置我的 maven 项目,以便使用 3.5.2 排除或覆盖 2.5.0 版本?我试过了
- 只设置属性
assertj.version - 在
starter-test dependency上添加排除项 - 在
spring-boot-dependencies上添加排除项
更新:
我正在为我的多模块项目中的所有模块设置一个自定义“测试”模块。我不仅需要 spring-test-starter,还需要一些其他依赖项和一些测试类和规则。
这是我的项目的样子:
my-module-root
|-my-module-a (using test)
|-my-module-b (using test)
\-test (including starter-test, ... - in COMPILE scope (because this is a test library))
现在,当我在测试模块(并包括 3.5.2)上排除 assertj-core 时,测试模块的依赖关系正常。 但是当我检查根级别的依赖项时,我在类路径上同时拥有 assertj-core-2.5.0 和 assertj-core-3.5.2。
【问题讨论】:
-
模块 A 和 B 是否在“测试”范围内包含模块测试?你确定你除了“test”模块之外没有包含任何spring-boot-starter-test?
-
是的,是的。双重检查。我将在github上创建一个小样本来验证...
标签: maven spring-boot