Spring 引导 - 配置文件激活其他配置文件



我正在开发一个 Spring 启动应用程序,并希望拥有类似于基本配置文件继承的东西。

我想知道如何存档以下内容:

if profile A.hello is active
then profile A.world needs to be activated as well

有没有办法做到这一点?

您可以通过自动连接环境变量来获取活动配置文件

@Autowired
Environment environment;
...
environment.getActiveProfiles()

最新更新