Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override property in application.groovy with external config in grails 3

There is no grails.config.locations property in grails 3 anymore, now Grails 3 uses Spring's property source concept instead, but how can I achieve the same behavior in grails 3 as it was in previous versions? Suppose I want to override some property property.to.be.overridden in application.grovy file with my external configuration file. How can I do it?

like image 889
airfox Avatar asked Oct 29 '15 17:10

airfox


1 Answers

The equivalent of grails.config.locations is spring.config.location

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-application-property-files

Here is an example specifying configuration locations while launching a jar from the command line(These same arguments can be used inside of your ide)

 java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties

Also since you mention wanting to override properties it's useful to learn the way Spring Boot handles profile specific property files(Multiple profiles may also be specified)

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-profile-specific-properties

like image 124
Zergleb Avatar answered Sep 28 '22 03:09

Zergleb