-
Notifications
You must be signed in to change notification settings - Fork 40.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default CGLib proxy setting default cannot be overridden by using core framework annotations (@EnableTransactionManagement, @EnableAspectJAutoProxy) #12194
Comments
Upgraded to Spring Boot 2.0 RC2. Adapted API changes in Spring Data, removed custom Streamable implementation and SalespointRepository. Re-enabled integration test that checks that unencrypted passwords cannot be persisted. Added EnforceJdkProxiesProcessor to make sure we continue to use JDK proxies so that we can use final methods in component implementations. See [0] for details. [0] spring-projects/spring-boot#12194
We have a test that disagrees with this statement. I think the problem is purely in I'll update |
Find this demo project showing that My extended inspection of also From a user point of view, I'd like to see explicit configuration using core Spring Framework means take precedence over Spring Boot defaults. |
Unfortunately, it's not as simple as that. The problem is that we're fighting against three different ways in the Framework that the proxy type can be configured:
Use of any of the three will define the Generally speaking, 1 and 3 aren't needed in a Boot app, so they are perhaps not too bad. However, 2 is required if you want to enable caching. We have no way of distinguishing between a user that just wants to enable caching and a user that wants to enable caching and override the type of proxies that are created. Given the above, I don't think we can do anything that would allow us to override the default using Framework's annotations. Instead, we really need to use a single context-wide switch to control the type of proxies that are created. We already have that switch in the form of the While looking at this issue I found some discrepancies in our javadoc and documentation. I've opened #12196 to take care of those. |
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 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 |
I meant that they aren't needed as both will be auto-configured for you. By contrast, if you want to enable caching you have to use
As far as I can tell, it's actually impossible to enforce JDK proxies. As soon as anyone uses an annotation with
That's a shame, and it would have been useful to have this feedback in mid-2016 when it was asked for. It's too late to change this in 2.0.
We might be able to use a
Unfortunately, a user's custom configuration can only trump Boot's defaults when it's clear what the custom configuration is intended to do. In terms of beans in the context relating to proxying, One possibility could be if Framework provided some sort of marker that allowed us to identify that |
I am not necessarily talking about enforcing but making thinks work the way they need in such a scenario out of the box. If someone can use the annotation to set this to
I did so. Both in exactly the comment below the one previously linked to and also a lot of in person discussions regarding Spring RESTBucks, just when the default was flipped.
I'm puzzled. They all have dedicated names. There is a strong contract of what they enable and what now. It might be the case that it's hard to diagnose at runtime which of the switches has been used. But that's something we should then probably bring up with Spring Framework. And no, I don't think anyone would be surprised that user configuration trumps application properties. No one is surprised that e.g. JDBC settings in
Here we go. I've filed SPR-16532 to improve that. |
I faced similar issue when I added Apache Shiro Web Starter in my project.
|
@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. |
Spring Boot 2.0 changes the default value for the configuration property
spring.aop.proxy-target-class
totrue
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 defaulttrue
gets applied.I.e. you see the same symptoms as described in #8434.
The text was updated successfully, but these errors were encountered: