Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

access to application properties (${appName}) in external configuration

Tags:

grails

I've externalized my Grails configuration basically the same way as the config file suggests. I've done it all the time with my 1.3 projects and the line

grails.serverURL = "http://localhost:8080/${appName}"

in the external config worked great. Now I experience the problem with 2.0 that Grails seems not to be able to resolve the ${appName} - it will use [:] instead in redirects.

As soon as I move this line back to the internal configuration, everything works fine.

Is there any way to move this configuration line to the external configuration? Am I doing something wrong?

like image 362
rdmueller Avatar asked Jan 31 '13 18:01

rdmueller


People also ask

How could you externalize constants from a spring configuration file into a properties file?

You can use properties files, YAML files, environment variables and command-line arguments to externalize configuration. Property values can be injected directly into your beans using the @Value annotation, accessed via Spring's Environment abstraction or bound to structured objects.

What are the possible sources of external configuration?

This way, a configuration can be provided from different sources, for example, file systems, the internet, external services, configuration services, vaults, etc.

Where do I put application properties in spring boot?

Spring Boot Framework comes with a built-in mechanism for application configuration using a file called application. properties. It is located inside the src/main/resources folder, as shown in the following figure.


1 Answers

You can use ${grails.util.Metadata.current.getApplicationName()} instead.

Note that since Metadata implements Map you can't shorten that to ${grails.util.Metadata.current.applicationName} since the key isn't applicationName.

like image 159
Burt Beckwith Avatar answered Oct 24 '22 13:10

Burt Beckwith