我正在使用Spring Batch(4.1.4.RELEASE)和SpringJars(4.0.9.RELEASE)运行一个tasklet,并得到异常:
Caused by: java.lang.IllegalStateException: A transaction manager must be provided**
at org.springframework.util.Assert.state(Assert.java:385) ~[spring-core-4.0.9.RELEASE.jar:4.0.9.RELEASE]
at org.springframework.batch.core.step.tasklet.TaskletStep.afterPropertiesSet(TaskletStep.java:129) ~[spring-batch-core-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1613) ~[spring-beans-4.0.9.RELEASE.jar:4.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1550) ~[spring-beans-4.0.9.RELEASE.jar:4.0.9.RELEASE]
... 41 more
下面我展示了基于会话工厂XML的配置。
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
<property name="hibernateProperties">
<value>
hibernate.show_sql=false
hibernate.format_sql=false
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.query.substitutions=true 'Y', false 'N'
hibernate.cache.use_second_level_cache=true
hibernate.cache.provider_class=net.sf.ehcache.hibernate.SingletonEhCacheProvider
hibernate.cache.use_query_cache=true
</value>
</property>
</bean>
<bean id="jdbcTransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
lazy-init="true">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="hibernatetransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"
lazy-init="true">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
我尝试了在Spring Batch和Spring核心库版本中进行一些更改,但都不起作用,我得到了相同的异常。
1条答案
按热度按时间jfewjypa1#
错误发生在
org.springframework.batch.core.step.tasklet.TaskletStep.afterPropertiesSet(TaskletStep.java:129) ~[spring-batch-core-4.1.4.RELEASE.jar:4.1.4.RELEASE]
中,这意味着您没有在微线程上设置事务管理器。您没有共享微线程的配置,但您需要确保在它上设置了事务管理器,这是必需的属性。