在我的应用程序中,我想在scope步骤中创建一些bean。我对entitymanagerfactory有一个问题,它给了我这个错误:org.springframework.beans.factory.beancreationexception:创建名为'scopedtarget.scopedtarget.entitymanagerfactory'的bean时出错:当前线程的作用域'step'不是活动的;如果您打算从单例引用这个bean,请考虑为它定义一个作用域代理;嵌套异常为java.lang.illegalstateexception:没有可用于步骤范围的上下文持有者
下面是我创建bean的方法。
<context:property-placeholder />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource" scope="step">
<aop:scoped-proxy/>
<property name="driverClassName" value="#{jobExecutionContext.get('batchProperties').getProperty('database.driverClass')}" />
<property name="url" value="#{jobExecutionContext.get('batchProperties').getProperty('database.url')}" />
<property name="username" value="#{jobExecutionContext.get('batchProperties').getProperty('database.user')}" />
<property name="password" value="#{jobExecutionContext.get('batchProperties').getProperty('database.password')}" />
</bean>
<bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter" scope="step">
<aop:scoped-proxy/>
<property name="databasePlatform"
value="org.eclipse.persistence.platform.database.PostgreSQLPlatform" />
<property name="generateDdl" value="false" />
<property name="showSql" value="true" />
</bean>
aop:scoped-proxy/
<bean id="stepScope" class="org.springframework.batch.core.scope.StepScope">
<property name="autoProxy" value="true" />
</bean>
<batch:job id="jobAccountDemo3456111" job-repository="jobRepository"
restartable="true">
<batch:step id="jobAccountDemo3456111.step1" parent="abstractParentStep">
<batch:tasklet>
<batch:listeners>
<batch:listener ref="loadPropertiesListener" />
</batch:listeners>
<batch:chunk reader="importAccountJobResourceReader" />
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="loadPropertiesListener" class="com.kmse.hicp.bof.batch.preset.gen.jpa.imports.PropertyLoaderJobExecutionListener" scope="step">
<property name="pfb">
<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="file:#{jobParameters['myfile']}" />
</bean>
</property>
</bean>
有办法解决这个问题吗
暂无答案!
目前还没有任何答案,快来回答吧!