@EnableTransactionManagement,@ComponentScan and DataSourceTransactionManager problems

spring, spring-transactions

Solution

One of the causes may be that your bean implements an interface.

When the bean implementing interface becomes `@Transactional`, a proxy should be created, as default it will be a JDK Proxy of the interface your class implements.

So because of the proxy, the bean now available only as interface(proxy) and not as the concrete class.

You should probably refactor your class - introduce another interface with service methods and reference it as interface and not as class.

See https://stackoverflow.com/a/8224772/241986

Problem

In my application, I am using annotation-based spring configuration. I was using `@ComponentScan` (and it worked fine). Now I'm trying to add simple transaction management using `@EnableTransactionManagement`. However, when I add it, I start getting errors with one of the beans not being found (i.e. I get `BeanCreationException` because of `NoSuchBeanDefinitionException`). There is no other error (i.e. there is nothing related to the transaction management). When I comment `@EnableTransactionManagement` out, everything works fine. I am trying to use this with a `DataSourceTransactionManager` What could be the reason?

Original source

Related problems