发布于 2019-09-22 18:52:53
IMHO,最明智的选择是在代码由BlockHound测试执行时启用JUnit。
要做到这一点,只需导入带有测试范围的https://mvnrepository.com/artifact/io.projectreactor.tools/blockhound-junit-platform依赖项,当启动JUnit测试套件时,该依赖项将自动初始化JUnit:
<dependency>
<groupId>io.projectreactor.tools</groupId>
<artifactId>blockhound-junit-platform</artifactId>
<version>1.0.0.RC1</version>
<scope>test</scope>
</dependency>或者,如果您打算在任何时候--而不仅仅是在测试期间--使用BlockHound,则应该导入以下依赖项:
<dependency>
<groupId>io.projectreactor.tools</groupId>
<artifactId>blockhound</artifactId>
<version>1.0.0.RC1</version>
</dependency>并在引导Spring应用程序之前,在主方法中调用BlockHound.install():
@SpringBootApplication
public class BlockhoundDemoApplication {
public static void main(String[] args) {
BlockHound.install();
SpringApplication.run(BlockhoundDemoApplication.class, args);
}
}如需进一步参考,请参阅:
https://stackoverflow.com/questions/58013744
复制相似问题