3

Spring 3.2 を使用するアプリに Spring Batch Admin を統合しました。

ここで、メソッドに で注釈を付け、@Scheduledこれを でアクティブ化しようとしてい<task:annotation-driven/>ます。webapp を起動すると、次の例外が発生します。

Caused by: java.lang.IllegalStateException: @Scheduled method 'removeInactiveExecutions'
found on bean target class 'SimpleJobService', but not found in any interface(s) for bean
JDK proxy. Either pull the method up to an interface or switch to subclass (CGLIB) proxies 
by setting proxy-target-class/proxyTargetClass attribute to 'true'

Spring Batch AdminのSimpleJobServiceは、メソッドでこのアノテーションを使用します。

春に 3.2。cglib をクラスパスに入れる必要はないようで、spring-asm も廃止されています。spring-asmspring-batch-integration から依存関係を除外しました。

どこで設定できますかproxy-target-class=true(私はすでに試着しました<tx:annotation-config><aop:config>

アプリケーションでどのように使用でき@Scheduledますか?

4

1 に答える 1

2

META-INF\spring\batch\override に execution-context.xml を追加し、SimpleJobServiceFactoryBean のプロキシを対象クラスに設定

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">


    <!-- Original jobRepository missing read ${batch.isolationlevel} -->
    <bean id="jobRepository"
        class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
        p:dataSource-ref="dataSource" p:transactionManager-ref="transactionManager" p:isolationLevelForCreate = "${batch.isolationlevel}"/>


    <!-- Original jobService conflicted with @EnableScheduling -->
    <bean id="jobService"
        class="org.springframework.batch.admin.service.SimpleJobServiceFactoryBean">
        <aop:scoped-proxy proxy-target-class="true" />
        <property name="jobRepository" ref="jobRepository" />
        <property name="jobLauncher" ref="jobLauncher" />
        <property name="jobLocator" ref="jobRegistry" />
        <property name="dataSource" ref="dataSource" />
        <property name="jobExplorer" ref="jobExplorer" />
        <property name="transactionManager" ref="transactionManager" />
    </bean>

</beans>
于 2015-12-22T10:57:38.373 に答える