Vinod Jayachandran
Vinod Jayachandran

Reputation: 3898

Unable to read Properties from .properties file in Grails App

I have a Property file under grails-app/conf with name config.properties

In my Config.groovy, I have properties as this

dfs.replication = '1'

In my Config.groovy, i have the following code

grails.config.locations = ["classpath:config.properties",
                           "classpath:config-${stage}.properties",
                          // "file:${configLocation}",
                           "${catalina.base}/../config/config.properties"
]

When I try to read grailsApplication.config.dfs.replication

I get below Error

Method threw 'groovy.lang.MissingPropertyException' exception.

Please help

Upvotes: 0

Views: 147

Answers (1)

Vinod Jayachandran
Vinod Jayachandran

Reputation: 3898

I had missed out on Autowiring grailsApplication in my Groovy File.

After Autowiring grailsApplication, it worked for me.

Thanks Vinod

Upvotes: 0

Related Questions