所以,我有一个是要反映我的应用程序运行在什么环境的环境特性。Java的春天@Value注释和参数
@Value("${environment}")
private String environmentName; //This will be set as sandbox, staging, production
我也有一个功能标志(功能称为“superFeature .enable')应该基于什么样的环境中应用已经部署在中设置。
//Config file
superFeature.enable.sandbox=true
superFeature.enable.staging=false
superFeature.enable.production=false
//@Service annotated class containing call to configuration
@Value("${superFeature.enable.{environment}:false}")
private boolean isSuperFeatureEnabled;
此刻,当我在沙箱环境中运行我的应用程序,isSuperFeatureEnabled
永远是假的。我的语法对于上面的代码片段是否正确?有什么我失踪?
所以,你的建议是,我应该通过在Java变量(environmentName)的名称,而不是名称配置(环境)? – GobiasKoffi