在 IDEA 中使用 JUnit Runner 时找不到 Spring 配置文件
Could not find Spring Profile when uses JUnit Runner in IDEA
我正在尝试 运行 在 IntelliJ IDEA 中进行 JUnit 测试,但 Runner 找不到 Spring 配置文件。
此消息显示在日志中:
--spring.profiles.active=dev
但紧接着:
Could not find key 'spring.profiles.active' in any property source
最后使用的配置文件是 default
这是我尝试在 IntelliJ 中设置配置文件的地方:
我找到问题了。当我删除 环境变量的“--”时一切正常。
这个: --spring.profiles.active
收件人: spring.profiles.active
在“构建和运行”下-->“环境变量:”,添加:
SPRING_PROFILES_ACTIVE=[profile name]
例如:
SPRING_PROFILES_ACTIVE=testing
我正在尝试 运行 在 IntelliJ IDEA 中进行 JUnit 测试,但 Runner 找不到 Spring 配置文件。
此消息显示在日志中:
--spring.profiles.active=dev
但紧接着:
Could not find key 'spring.profiles.active' in any property source
最后使用的配置文件是 default
这是我尝试在 IntelliJ 中设置配置文件的地方:
我找到问题了。当我删除 环境变量的“--”时一切正常。
这个: --spring.profiles.active
收件人: spring.profiles.active
在“构建和运行”下-->“环境变量:”,添加:
SPRING_PROFILES_ACTIVE=[profile name]
例如:
SPRING_PROFILES_ACTIVE=testing