Closed chenrui333 closed 8 years ago
It should work, @EnableEncryptableProperties
imports some configuration that registers a BeanFactoryPostProcessor
to decorate property sources present in the Environment.
@EncryptablePropertySource
is simpler, it just enables one specific property source with jasypt capabilities.
Do you have (or can create) a test app in Github where the problem manifests?
@ulisesbocchio Thanks for the reply. I will upload a sample later.
But I saw the spring-boot package get used in the EnableEncryptablePropertySourcesPostProcessor.java
, could it be a problem?
Here is ref repo: https://github.com/chenrui333/jyspert-spring-sample
The command line to run is ./gradlew appRun
jasypt-spring-boot
does not work with vanilla Spring as properties source loading is different,
Spring Boot used PropertySourceLoader
, while vanilla Spring used PropertySourcesPlaceholderConfigurer
Alright, let me take a look at your project...sorry for the delay
Thanks.
Any update?
I'll get back to you today... sorry for the delay
You're missing this in your TestConfig:
@Bean
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
That's mandatory if you want to enable PropertySources in general. Basically, without that bean, not even Spring's @PropertySource
annotation works. In Spring Boot, there's an auto configuration for it in org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
Let me re-try it. UPDATE: Works pretty good! Thanks!
Another quick question is that whether I can use gradle to setup system property that it can be picked up by Spring configuration.
you gotta pass the system property to tomcat or whatever servlet container you're using when you run your application if you use it out of the box. Otherwise you can define your own SpringEncryptor bean and retrieve the password from wherever you want.
I did not see Jasypt have official support for Spring 4/5, but when I tried to include
@EnableEncryptableProperties
and@EncryptablePropertySource
, it does not work as expected.