Is a proxy created for each Bean in Spring?

Viewed 1007
1 Answers

Spring creates proxy for a bean only if required ( example:Transaction management). I have explained this for another SO question here , please go through A2 section of the answer for more details.

For a @Configuration annotated class a proxy will always be created , which implies that it is required. Why it is required can be understood from the following references.

@Bean : Read through sections @Bean Methods in @Configuration Classes and @Bean Lite Mode

Do read through this excellent answer from @kriegaex to understand the inner workings of @Configuration class.

So to answer your question is a proxy created for each @Configuration ? Yes , unless the proxyBeanMethods for @Configuration is configured explicity.

Hope this helps.

Related