apache / shardingsphere-elasticjob

Distributed scheduled job
Apache License 2.0
8.15k stars 3.29k forks source link

spring名称空间及配置相关问题 #148

Closed ghost closed 8 years ago

ghost commented 8 years ago

maven:

使用名称空间的elastic-job的spring配置:

<reg:zookeeper id="regCenter" server-lists="10.211.55.6:2181" namespace="dd-job" base-sleep-time-milliseconds="1000" max-sleep-time-milliseconds="3000" max-retries="3" />
<job:simple id="oneOffElasticJob" class="com.demo.elasticJob.MyElasticJob" registry-center-ref="regCenter" cron="0/10 * * * * ?" sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" />

启动spring容器后,抛出如下异常:

Caused by: java.lang.NoClassDefFoundError: com/dangdang/ddframe/reg/zookeeper/ZookeeperRegistryCenter

不使用名称空间的elastic-job的spring配置:

  1. ZookeeperRegistryCenter: 使用spring bean方式注册
<bean id="syncJobRegCenter"
            class="com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter"
            init-method="init">
        <constructor-arg>
            <bean class="com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration">
                <property name="serverLists" value="10.211.55.6:2181"/>
                <property name="namespace" value="dd-job"/>
                <property name="baseSleepTimeMilliseconds" value="1000"/>
                <property name="maxSleepTimeMilliseconds" value="3000"/>
                <property name="maxRetries" value="3"/>
            </bean>
        </constructor-arg>
    </bean>
  1. SpringJobScheduler
<bean id="demoJobSchedule" class="com.dangdang.ddframe.job.spring.schedule.SpringJobScheduler" >
        <constructor-arg name="coordinatorRegistryCenter" ref="syncJobRegCenter"/>
        <constructor-arg name="jobConfigurationDto" ref="jobConfiguration"/>
    </bean>

demoJobSchedule的构造参数 jobConfigurationDto 应该是AbstractJobConfigurationDto 的子类,但子类SimpleJobConfigurationDto非public修饰,外部无法引用

terrymanu commented 8 years ago

elastic-job-lite-core 2.0.0和elastic-job-spring 1.1.1是不能一起用的,版本号需要统一

ghost commented 8 years ago

非常感谢, 已解决问题。

还有一个疑惑,利用数据库跟踪作业执行,这个数据必须是指定的吗(mysql, oracle或其他)?尝试了下oracle, 并提前在数据库把表结构创建好, 但是在作业执行的时候,抛出 ORA-00922: missing or invalid option 异常。

On Oct 30, 2016, at 19:58, 张亮 notifications@github.com wrote:

elastic-job-lite-core 2.0.0和elastic-job-spring 1.1.1是不能一起用的,版本号需要统一

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dangdangdotcom/elastic-job/issues/148#issuecomment-257146862, or mute the thread https://github.com/notifications/unsubscribe-auth/ARCg_hS6F3v8G3HbvfptJGzw_JT8ko0sks5q5IZMgaJpZM4KkTD4.