Created
May 22, 2013 16:31
-
-
Save danveloper/5628959 to your computer and use it in GitHub Desktop.
Accessing Grails Configuration with Spring Property Placeholders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.objectpartners.application.config | |
config { | |
social { | |
twitter { | |
consumerKey = "ABCD" | |
consumerSecret = "EFGH" | |
accessToken = "IJKL" | |
accessTokenSecret = "MNOP" | |
} | |
faceboook { | |
... | |
} | |
linkedin { | |
... | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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