Sobes.tech
Senior

At what stage are proxies created (for @Transactional, @Async, etc.)?

sobes.tech AI

Answer from AI

Proxies for annotations such as @Transactional or @Async in Spring are created during the application context initialization phase, during bean creation.

When Spring scans classes and detects beans with annotations requiring aspect-oriented behavior, it creates proxy objects around these beans. This occurs after the bean instance is created but before it is used in the application.

Proxies intercept method calls and add additional logic, such as transaction management or asynchronous execution. Thus, proxies are created during the configuration and initialization of the Spring context, before the bean becomes available for use.