简体   繁体   English

使用通配符“ *”来匹配application.conf中的任何内容

[英]Using wildcard character '*' to match anything in application.conf Play application

Is there a way to specify Wildcard character like '*' to match anything. 有没有一种方法可以指定通配符(例如“ *”)来匹配任何内容。 For Eg: I want to specify the configuration like this in application.conf. 例如:我想在application.conf中指定这样的配置。

application.*.config = value1

In the application I want this "value1" to get picked up for any of the below keys I specify. 在应用程序中,我希望为我指定的以下任何键选择“ value1”。

application.test.config  
application.prod.config  
application.staging.config

How can I achieve this? 我该如何实现?

No there is not, you have two solutions 不,没有,您有两种解决方案

  1. You can use application modes ( Dev , Prod or Test ) ie like this: 您可以使用应用程序模式( DevProdTest ),例如:

     application { Dev.value = "My value for DEV" Prod.value = "My value for PROD" Test.value = "My value for TEST" } // controller String myValue = Play.application().configuration().getString("application." + Play.application().getWrappedApplication().mode().toString() + ".config"); 
  2. You can create 3 alternative configs for your states and override ONE param ie application.config , of course you will need to specify required alt. 您可以为状态创建3个替代配置,并覆盖一个参数(即application.config ,当然,您需要指定所需的alt。 config file while running in given mode. 在给定模式下运行时的配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM