I solved it a little differently, so I could upload an external YAML file.
Application.groovy
package com.mycompany.myapp import grails.boot.GrailsApp import grails.boot.config.GrailsAutoConfiguration import org.springframework.beans.factory.config.YamlPropertiesFactoryBean import org.springframework.context.EnvironmentAware import org.springframework.core.env.Environment import org.springframework.core.env.PropertiesPropertySource import org.springframework.core.io.FileSystemResource import org.springframework.core.io.Resource; class Application extends GrailsAutoConfiguration implements EnvironmentAware { static void main(String[] args) { GrailsApp.run(Application) } @Override void setEnvironment(Environment environment) { String configPath = System.properties["myapp.config.location"] if (configPath) { Resource resourceConfig = new FileSystemResource(configPath); YamlPropertiesFactoryBean propertyFactoryBean = new YamlPropertiesFactoryBean(); propertyFactoryBean.setResources(resourceConfig); propertyFactoryBean.afterPropertiesSet(); Properties properties = propertyFactoryBean.getObject(); environment.propertySources.addFirst(new PropertiesPropertySource("myapp.config.location", properties)) } } }
Then I specify the YAML file when I run it
command line
java -jar -Dmyapp.config.location=/etc/myapp/application.yml build/libs/myapp-0.1.war
source share