You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@EnableTransactionManagement proxyTargetClass not control by spring.aop.proxyTargetClass #8434
if use @Transactional,and set spring.aop.proxyTargetClass=false, this class also create by cglib not jdk proxy,you must config @EnableTransactionManagement(proxyTargetClass=false) to use jdk proxy with @Transactional
@Service
public class DemoServiceImpl implements DemoService {
@Transactional
public void test() {
System.out.println("Test");
}
}
And @EnableTransactionManagement proxyTargetClass default value is false, why spring boot change to true?
Sorry, I misunderstood your initial comment. You're saying you add spring.aop.proxyTargetClass=false to application.properties but we ignore that and use cglib regardless?
the spring.aop.proxy-target-class is only used to toggle the configuration in AopAutoConfiguration for other proxy creation it is being ignored, like for @EnableTransactionManagement and the configuration of the PersistenceExceptionTranslationPostProcessor.
I noticed this during introducing Spring Boot into a project which used quite a lot of final classes (or classes with final methods). I ran into it in those areas but maybe there are a few more (like JMX for instance).
@philwebb I've worked on a solution in b20dff1 that is a bit larger than what is foreseen here. I am not sure if that belongs to 1.4 but a couple of thoughts:
Our default for this is CGLIB which basically upgrade the whole context to go CGLIB. IMO we should change the default of spring.aop.proxy-target-class to true
So far we only enabled transaction management when a DataSource is present. That led to the Neo4j problem (Auto-configure @EnableTransactionManagement with Neo4J #8587) but any data tech that supports PlatformTransactionManager is also affected. IMO it makes more sense to enable it once such a bean is found in the context
I think that 1. is pretty bad because we won't be able to change it in 1.4 or 1.5 and currently we're doing that effectively as soon as you use @Transactional in your app.
Activity
philwebb commentedon Feb 28, 2017
This was changed in 1.4 (see #5423). We've generally found cglib proxies less likely to cause unexpected cast exceptions.
philwebb commentedon Feb 28, 2017
Sorry, I misunderstood your initial comment. You're saying you add
spring.aop.proxyTargetClass=falsetoapplication.propertiesbut we ignore that and use cglib regardless?Dreampie commentedon Feb 28, 2017
yes,@snicoll know this question,https://github.com/Dreampie/spring-boot-demo
mdeinum commentedon Mar 5, 2017
the
spring.aop.proxy-target-classis only used to toggle the configuration inAopAutoConfigurationfor other proxy creation it is being ignored, like for@EnableTransactionManagementand the configuration of thePersistenceExceptionTranslationPostProcessor.I noticed this during introducing Spring Boot into a project which used quite a lot of
finalclasses (or classes withfinalmethods). I ran into it in those areas but maybe there are a few more (like JMX for instance).snicoll commentedon Mar 13, 2017
While we're working on it, we may want to share that thing in its own auto-configuration and order that in a sensible manner, see #8587
Enable transaction management consistently
snicoll commentedon Mar 17, 2017
@philwebb I've worked on a solution in b20dff1 that is a bit larger than what is foreseen here. I am not sure if that belongs to 1.4 but a couple of thoughts:
spring.aop.proxy-target-classtotrueDataSourceis present. That led to the Neo4j problem (Auto-configure@EnableTransactionManagementwith Neo4J #8587) but any data tech that supportsPlatformTransactionManageris also affected. IMO it makes more sense to enable it once such a bean is found in the contextI think that 1. is pretty bad because we won't be able to change it in 1.4 or 1.5 and currently we're doing that effectively as soon as you use
@Transactionalin your app.Enable transaction management consistently
Automatically enable transaction management for Neo4j