0

Spring doc mentions "lite" mode @Bean where the annotation is declared not within a @Configuration class.

The primary difference seems to be whether the @Bean method is proxied by cglib.

But practically, when is it a good fit to use lite mode @Bean methods (over a plain java method)?

wlnirvana
  • 1,501
  • 15
  • 30
  • The short answer never, as it only leads to unexpected behavior. A lite bean method is basically just a simple factory method, each time it is called it will create a new instance (that is the lite part, and the part that leads to confusion). – M. Deinum May 26 '21 at 06:11
  • It can be used when there is requirement to have two beans (instances) of same type, where each instance behaves differently (different constructor args etc.). – user3734782 May 26 '21 at 08:41

0 Answers0