Skip to content

Instantly share code, notes, and snippets.

@danveloper
Created May 22, 2013 16:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save danveloper/5628959 to your computer and use it in GitHub Desktop.
Accessing Grails Configuration with Spring Property Placeholders
package com.objectpartners.application.config
config {
social {
twitter {
consumerKey = "ABCD"
consumerSecret = "EFGH"
accessToken = "IJKL"
accessTokenSecret = "MNOP"
}
faceboook {
...
}
linkedin {
...
}
}
}
class TwitterService {
@Value('${config.social.twitter.consumerKey}')
private String consumerKey
@Value('${config.social.twitter.consumerSecret}')
private String consumerSecret
@Value('${config.social.twitter.accessToken}')
private String accessToken
@Value('${config.social.twitter.accessTokenSecret}')
private String accessTokenSecret
TwitterTemplate createTwitterTemplate() {
new TwitterTemplate(consumerKey, consumerSecret, accessToken, accessTokenSecret)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment