Skip to content
Advertisement

Bean init before DataSourceAutoConfiguration

I have bean (transformerColumnKeyLoader) which sould be inited before DataSourceAutoConfiguration. Purpose of that bean is replace placeholers in anotation on entity properties with key for cyphering. I had that code of configuration which worked well before (order was good):

JavaScript

But after adding some new beans, now isn’t working. And first initialized is DataSourceAutoConfiguration and after that init transformerColumnKeyLoader bean.

Advertisement

Answer

I found simple solution. I break bean out of resolving dependencies and I’m trigering by Spring application event. I had inspiration by comment. My solution is:

JavaScript

Event Listener

JavaScript

The great is I’m able to access to properties and this is trigered before all beans.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement