据我所知,没有什么可以直接解决您的请求-但我可以提出一项建议,可以帮助您:
您可以使用自己的测试注释,该注释是包含
@SpringBootTest和的元注释
@ActiveProfiles("test")。因此,您仍然需要专用的配置文件,但要避免在所有测试中分散配置文件定义。该注释将默认为配置文件
test,您可以使用元注释覆盖配置文件。
@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)@SpringBootTest@ActiveProfilespublic @interface MyApplicationTest { @AliasFor(annotation = ActiveProfiles.class, attribute = "profiles") String[] activeProfiles() default {"test"};}


