Using External Properties for Spring Social Connection Keys

Spring Social Connection Keys like Facebook AppIds and Twitter Consumer Secrets are usually found in, but you might want to keep these outside of your application. I blogged about using Spring external properties before, that time using them in Thymeleaf HTML. This post will be similarly short and sweet, but I wanted to write it up to help fellow developers get up and running with NixMash Spring Social more quickly.

Let's start with the essential source where we configure the Connection Factories. I should note that if you're using Spring Boot and using the correct Spring Social Property Names in it's not necessary to even include addConnectionFactories() for entering the connection keys. We're using our External Properties file so we're including it.

ApplicationSettings POJO Component

Our ApplicationSettings is a plain old Java object class. As a sidebar, most of the NixMash Spring Social action happens in project MVC, but ApplicationSettings is located in a referenced Project (JPA) which is a good example of cross-project Beans at work.

Notice the @ConfigurationProperties “external” prefix for property names, so the file looks something like this.

Source Code Notes for this Post

All source code discussed in this post can be found in my NixMash Spring GitHub repo and viewed online here.

Posted March 08, 2016 12:02 PM EST

More Like This Post