1
我只是不明白。使用@Serviced標記並通過@ComponentScan在應用程序上下文中註冊的bean是否通過@Transaction批註代理了事務支持?@Transaction @Service在Spring註釋配置
這工作得很好:
public class LocationManagerImpl implements LocationManager {
@Transactional
public void saveLocation(Location location) {
}
}
//config class
@Bean
public LocationManager locationManager() {
return new LocationManagerImpl();
}
,這並不:
@Service
public class LocationManagerImpl implements LocationManager {
@Transactional
public void saveLocation(Location location) {
}
}
ComponentScan註釋用於@Configuration類。你有上下文:你的應用程序上下文中的組件掃描? – jeff 2012-08-07 15:31:31
我的配置是基於註釋的,我在標記爲\ @Configuration的類中應用\ @ComponentScan。服務已創建,但事務支持不起作用。 – 2012-08-07 18:07:11
當您使用第二種方法並嘗試從上下文中獲取LocationManager時,是否有?它在那裏,但只是沒有代理交易?還是完全缺失? – jeff 2012-08-07 18:46:15