I want to add properties files encryption with Jasypt in my Spring 4 app (without Spring Boot). The configuration is in Java.
I found solution for Spring 3.1 XML config, and for Spring Boot but not Spring4 Java config.
I tried declaring it as suggested in the doc for 3.1 (http://www.jasypt.org/spring31.html) in a Java config way, but it doesn't load the properties.
@Bean
public EncryptablePropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
EncryptablePropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new EncryptablePropertyPlaceholderConfigurer(new OurCustomEncryptor());
propertyPlaceholderConfigurer.setLocations(
new ClassPathResource("config-encrypted.properties")
);
return propertyPlaceholderConfigurer;
}
Any idea?