We know that Spring uses proxies for specific features like AOP and transaction management. But does it use Java dynamic proxies or CGLib proxies for handling Beans ? If so wouldn't that carry a performance penalty ?
Asked
Active
Viewed 181 times
0
-
It depends what you configured Spring to do and if you use Spring Boot or not. By default it depends if you are implementing interfaces it will use dynamic proxies, else it will use Cglib proxies. You can also force the use of one or the other. Spring Boot by default switches to class based proxies. – M. Deinum Jul 23 '18 at 17:53
-
Regardless of the type of the proxy, does spring use proxies after setting up the application context ? Wouldn't it be an overkill have everything called through a proxy ? – psaw.mora Jul 24 '18 at 00:24
-
Creating a proxy is done while starting the application context. What makes you think *everything* is being proxied? Only things that need proxying (like `@Transactional`) are being proxied, beans that don't need proxying aren't proxied. – M. Deinum Jul 24 '18 at 05:37