【发布时间】:2021-07-08 03:50:34
【问题描述】:
我的应用程序在主资源和测试资源文件夹中有 application.yml,但是应用程序(带有 Maven 的 Spring boot 2.4)抱怨找不到 application.properties。
以下是错误。
2021-07-08 04:37:33.381 ERROR --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@bd4ee01] to prepare test instance [com.test.SomeTests@6a7aa675]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
...
Caused by: java.io.FileNotFoundException: class path resource [application.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:187)
我试图在网上找到解决方案,但找不到。请帮忙。
【问题讨论】:
-
听起来你有一个测试在某处明确指定
application.properties,而不是使用引导基础设施。 -
嗨@chrylis-cautiouslyoptimistic-感谢您的快速回复。你是对的。
标签: java spring spring-boot maven