I just cannot understand. Are beans marked with @Serviced and registered in application context by @ComponentScan proxied for transaction support via @Transaction annotation?
This works fine:
public class LocationManagerImpl implements LocationManager {
@Transactional
public void saveLocation(Location location) {
}
}
//config class
@Bean
public LocationManager locationManager() {
return new LocationManagerImpl();
}
and this doesn’t:
@Service
public class LocationManagerImpl implements LocationManager {
@Transactional
public void saveLocation(Location location) {
}
}
The problem is likely that your
@Transactionalannotated class is situated in the servlet context. This may happen if you have<context:component-scan>in your servlet application context configuration, while Spring AOP interceptors are configured in the root application context.The solution is to move
@Serviceannotated classes to the root web app application context.See Spring @Transactional not working.
The difference between Servlet and Web App Root context:
Difference between applicationContext.xml and spring-servlet.xml in Spring Framework.