spring Conditional bean registration in Spring

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9

Remarks

Important point to note while using condition

  • The condition class is referred as direct class (not as spring bean) so it can't use the @Value property injection i.e. no other spring beans can be injected within it.
  • From java docs - Conditions must follow the same restrictions as BeanFactoryPostProcessor and take care to never interact with bean instances. The restrictions refereed here are A BeanFactoryPostProcessor may interact with and modify bean definitions, but never bean instances. Doing so may cause premature bean instantiation, violating the container and causing unintended side-effects.


Got any spring Question?