Skip to content

Category: Java

Secure Your Java Spring App With PropertyPlaceholderConfigurer

This is a trick that I have used many times which I first learned about on Mkyong.com – one of my favorite Java/Spring/Hibernate resources.

Just about any application will need to connect to external resources like databases, web services, file servers, and the like. And, if you are working on a corporate application or in an environment where your source control system like SVN or GIT is not a safe place to keep passwords, this can cause quite a security conundrum.

Enter Spring’s PropertyPlaceholderConfigurer class, one of the handiest little classes. It’s actually worth adding Spring in your application just to get access to this little gem. What this does is it allows you to load a properties file into your Spring configuration XML, and use its properties – thereby removing the sensitive content from the XML file.