Default CGLib proxy setting default cannot be overridden by using core framework annotations (@EnableTransactionManagement, @EnableAspectJAutoProxy)
See original GitHub issueSpring Boot 2.0 changes the default value for the configuration property spring.aop.proxy-target-class
to true
if nothing is configured. This causes an explicit @EnableAspectJAutoProxy(proxy-target-class = false)
not being picked up anymore. Also an explicit @EnableTransactionManagement(proxy-target-class = false)
is not causing transactional proxies being created as JDK proxies anymore as the default true
gets applied.
I.e. you see the same symptoms as described in #8434.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Spring-Boot 2+ forces CGLIB proxy even with ... - Stack Overflow
It's a known issue. Currently you can only set spring.aop.proxy-target-class=false. in your config file to force it to use JDKProxy.
Read more >Configuration (Spring Framework 6.0.2 API)
Enabling built-in Spring features using @Enable annotations See @EnableAsync , @EnableScheduling , @EnableTransactionManagement , @EnableAspectJAutoProxy , and ...
Read more >惊人!Spring5 AOP 默认使用Cglib? 从现象到源码深度分析
issue:Default CGLib proxy setting default cannot be overridden by using core framework annotations (@EnableTransactionManagement, ...
Read more >Spring cert study Flashcards - Quizlet
To enable component scanning, annotate a configuration class in your Spring application with the @ComponentScan annotation. The default component scanning ...
Read more >Core Technologies - simviso
By default, when the Spring container creates a proxy for a bean that is marked up with the <aop:scoped-proxy/> element, a CGLIB-based class ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s sorry to hear as as far as I can see, this is the first occasion that I encounter, that Boot doesn’t respect standard Spring user configuration, which breaks the “Boot fills configuration gaps and respects what you’ve configured explicitly.” story.
Regarding the “aren’t needed in a Boot app” statement. I don’t think I can agree with this. If you want to ship code that by definition can’t use CGLib proxies (e.g. because the code is deliberately using interfaces to allow
final
methods in the interface implementation) and you want to make sure that this code works as expected, shipping a configuration class that enforces JDK proxies is a reasonable option. Relying on someone downstream configuring the property in a special way is cumbersome as it creates much bigger distance between the code that needs the setting and where the setting is configured.I haven’t been too happy with the switch to CGLib proxies by default in the first place as CGLib still imposes quite severe limitations on the code being written. That switch in default that was basically a convenience switch and was considered to not have any implications now basically leads to one of Boot’s core principles to be undermined. Even worse, we break the usually pretty helpful Spring Framework error messages as the log output you get in the error case suggests to set
proxyTargetClass
tofalse
which is exactly what you have in place and thus probably leaves you puzzled as nothing leaves a trace that some Boot default affects this and we’ve spent years training users to expect their custom configuration trump Boot’s defaults.@amol204 please don’t comment on a closed issue to get support. If you have a question please ask on StackOverflow or come chat with the community on Gitter. Also, Shiro is not handled here.