2
我使用@Transactional和通過註釋進行事務管理(tx:annotation-driven ...)。我有,當我使用GenericApplicationContext從它創建應用程序上下文,並得到一些豆類問題:@Transactional和GenericApplicationContext不能一起工作
GenericApplicationContext ctx = new GenericApplicationContext();
// Load beans definitions
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
xmlReader.loadBeanDefinitions(new ClassPathResource(CONTEXT_PATH));
// Register the datasource
ctx.getBeanFactory().registerSingleton(CONTEXT_DATASOURCE_BEAN_NAME, dataSource);
// Get the service
ServiceInterface service = (ServiceInterface) ctx.getBean("service");
我有serviceInterface等的實例,但我想有一個包含有關交易信息的代理。
你能向我解釋我錯過了什麼嗎?
究竟哪些方法無效?你如何配置交易? – axtavt
我在服務和dao類上使用@Transactional註釋,並在配置xml中使用。在上面顯示的代碼中,我調用bean「service」並獲取它,但是實例的類,但我需要與TransactionInterceptor代理。我如何繼續按照我所展示的方式創建上下文之後進行事務性註釋? –
user1802311
基本上我的問題是非常相似的:http://forum.springsource.org/showth...-via-a-factory 我想在豆工廠創建的bean事務。如何從bean工廠獲取bean後繼續進行事務註釋? – user1802311