0

I have config variable(in application.yml) as:

xyz:
exception.emails: ['abc@gmail.com']

While fetching this in local works fine but after deploying war I am getting config variable as:

xyz: [
    exception: [
        emails[
            0
        ]: abc@gmail.com
    ]
]

I am pulling this as:

def email = Holders.config.grails.xyz.exception.emails
Dovydas Šopa
  • 2,282
  • 8
  • 26
  • 34

1 Answers1

0

I'm actually surprised this work at all, because I don't think that is proper yml syntax looking at the default application.yml they specify a list of userAgents like this:

grails:
    mime:
        disable:
            accept:
                header:
                    userAgents:
                        - Gecko
                        - WebKit
                        - Presto
                        - Trident

Personally I like to use an application.groovy and use groovy syntax like this:

grails {
    mime {
        disable {
            accept {
                header {
                    userAgents:
                    ['Gecko', 'WebKit', 'Presto', 'Trident']
                }
            }
        }

It maybe a little out of date but here is an example of a application.yml converted to application.groovy: https://github.com/virtualdogbert/Grails3Tutorial/blob/step_01_settings_yml_to_groovy/grails-app/conf/application.groovy

Also note in the past you could run code from application.groovy, however if you have any imports they won't work,because application.yml/groovy, is meant for the cli(pre runtime), so as a workaround you can also specify a runtime.groovy, where you can have imports. If you ever go the extra mile and write a plugin, you can specify a plugin.groovy, to set defaults.

virtualdogbert
  • 462
  • 3
  • 12