简体   繁体   中英

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.*.config = value1

In the application I want this "value1" to get picked up for any of the below keys I specify.

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:

     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. config file while running in given mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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