Closed netwolfuk closed 5 years ago
alright, will take a look and see if there's a bug...in Spring. The starter jar uses the exact same config as the annotation, literally. The only difference is when they're loaded. In theory, there should be no difference since the spring.factories beans and the application-provided beans end up in the same context, and the BeanFactoryPostProcessor that loads the encryption config should be triggered after ALL bean are loaded, hence the name "post processor". But you never know...
Perhaps I was doing something wrong. When I made this little change it started working. I don't think I did anything else, but can look back through the git history if you want me to.
Just re-reading your comment:
the BeanFactoryPostProcessor that loads the encryption config should be triggered after ALL bean are loaded
I wonder if this is the problem for me.
I need some beans to be loaded, so that I can constructor inject the PasswordProvider
, but other beans will need the @Value
decrypted for them to be instantiated.
Perhaps that is more the issue, and it's a subtle chicken and egg problem.
Yeah, sounds like you’re onto something there. If you pull properties on the lifecycle of your encryptor bean...
Thanks for this niubility lib firstly and thanks for netwolfuk ! I met the same trouble. use ur way then ok. should use jaspyt-spring-boot not starter and use @EnableEncryptableProperties magic . This magic must to be placed on the Springboot start class.
I'm not having this issue, using spring-boot-starter-parent
version 2.1.2
Maybe, It's the bug for springboot 1.5.x.
I tried both the starter and annotation ways on all demo apps and everything works fine with spring boot 2.X. Seems like an issue with spring boot 1.X
TL;DR Could you make it more obvious from the docs that if you have a custom
@Bean("jasyptStringEncryptor")
, you can't usejasypt-spring-boot-starter
, you must usejasypt-spring-boot
and@EnableEncryptableProperties
Firstly. thanks for such a great library.
We are using Spring 1.5.x, so I am using jasypt-spring-boot 1.17
I had a requirement to load the password from another file, so built a custom
StringEncryptor
and inject the password resolver with spring. eg, I do it like this.However, if I used
jasypt-spring-boot-starter
, it would not use my custom encryptor, but instead would complain that I had not passed in the password with--jasypt.encryptor.password
Switching to
jasypt-spring-boot
and removing the autoconfigure magic, but adding@EnableEncryptableProperties
worked around this issue.The weird thing was that it would work in Eclipse in Windows, but not when the SpringBoot app was bundled as a jar and run on our Linux dev server (eg,
java -jar app.jar
).I'm not sure this is a bug in 1.17, but it might help someone else if that was a little more obvious in the documentation that the two are not compatible.
Also, "wanna" is not a valid english word. It would be nice to replace all "wanna" with "want to" in your docs.