[英]How can I correct Spring Boot unit test failed to load application context in one of two nearly identical test classes?
I am building unit tests for a Spring Boot application that will call a couple of web services.我正在为 Spring 引导应用程序构建单元测试,该应用程序将调用几个 web 服务。 One service builds a PDF and the other stores that document, and there are separate classes to call these services.
一个服务构建 PDF 和其他存储该文档的存储,并且有单独的类来调用这些服务。 I'm using IntelliJ for an IDE.
我将 IntelliJ 用于 IDE。
When I have a single test class to run all of my tests, things start up and work fine.当我有一个测试 class 来运行我的所有测试时,一切都会启动并正常工作。 When I have two separate test classes, the first class continues to work fine but when running the second I receive
当我有两个单独的测试类时,第一个 class 继续正常工作,但在运行第二个时我收到
ERROR [main] org.springframework.boot.SpringApplication: Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name...
Could not resolve placeholder 'PDF.form.serviceURL' in value "${PDF.form.serviceURL}"
The classes are annotated with the following, for the application context to start这些类使用以下注释,以启动应用程序上下文
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
What would cause one test class to run without issue, and an identical test class to fail to start the application context?什么会导致一个测试 class 运行没有问题,以及一个相同的测试 class 无法启动应用程序上下文?
In this scenario, the problem was related to the JUnit configuration in IntelliJ.在这种情况下,问题与 IntelliJ 中的 JUnit 配置有关。 Without the appropriate environment options, the context would not start correctly, causing the error.
如果没有适当的环境选项,上下文将无法正确启动,从而导致错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.