我有一个 SpringBootTest,我想在现有配置文件中添加一个 spring-profile 以进行特定测试。我试过@SpringBootTest(webEnvironment = RANDOM_PORT, properties = "spring.profiles.include=my-second-profile")
https://github.com/spring-projects/spring-boot/issues/7668 中建议的但这根本不起作用。现在只有包含的配置文件处于 Activity 状态。因此,我的上下文无法启动,因为默认 Activity 配置文件中所需的属性丢失。有谁知道如何解决这个问题吗?
谢谢!
最佳答案
properties
需要一个数组 String[]
,而不是单个对象 String
。
@SpringBootTest(webEnvironment = RANDOM_PORT,properties = {"spring.profiles.include=my-second-profile"})
用 {}
包围您的字符串,它应该可以工作。
关于java - 将 spring 配置文件添加到 SpringBootTest 中的现有配置文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60560012/