[英]Springboot - application-integration.properties working under src/main/resources, but not under src/test/resources
Small question regarding a Spring profile (integration) applied to Springboot please.请关于适用于 Springboot 的 Spring 配置文件(集成)的小问题。
Currently, under src/main/resources, I have several application.properties files.目前,在 src/main/resources 下,我有几个 application.properties 文件。 Such as:如:
And under the src/test/resources, no properties file.并且在 src/test/resources 下,没有属性文件。
When I run maven, maven will trigger some unit and integration tests.当我运行 maven 时,maven 会触发一些单元和集成测试。 The unit test does not need any particular profile (properties are set in the unit tests, anyway, it is not the question).单元测试不需要任何特定的配置文件(属性在单元测试中设置,无论如何,这不是问题)。
The integration tests, they need the application-integration.properties.集成测试,他们需要 application-integration.properties。 And currently, with the file under src/main/resources, everything is fine.目前,使用 src/main/resources 下的文件,一切都很好。
I just tried moving the file to src/test/resources, and the integration tests could not find any property, as if the file disappeared.我刚刚尝试将文件移动到 src/test/resources,集成测试找不到任何属性,好像文件消失了一样。
What is the proper way to tell Springboot to run integration tests with a application-integration.properties under src/test/resrouces please?请告诉 Springboot 使用 src/test/resrouces 下的 application-integration.properties 运行集成测试的正确方法是什么?
Thank you谢谢
You can use the below configuration for the Integration tests您可以将以下配置用于集成测试
@TestPropertySource(locations = "classpath:application-integration.properties")
@ActiveProfiles("integration")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.