@Transactional和GenericApplicationContext无法一起使用

时间:2012-11-06 07:37:46

标签: java spring spring-transactions

我正在通过注释使用@Transactional和事务管理(tx:annotation-driven ...)。当我使用GenericApplicationContext创建应用程序上下文并从中获取一些bean时,我遇到了问题:

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的实例,但我想拥有包含有关事务的信息的代理。

你能解释一下我错过了什么吗?

0 个答案:

没有答案
相关问题