xuxueli / xxl-job

A distributed task scheduling framework.(分布式任务调度平台XXL-JOB)
http://www.xuxueli.com/xxl-job/
GNU General Public License v3.0
27.35k stars 10.82k forks source link

@RefreshScope 与XxlJobSpringExecutor不兼容 #2746

Open 419572718 opened 2 years ago

419572718 commented 2 years ago

Please answer some questions before submitting your issue. Thanks!

Which version of XXL-JOB do you using?

2.0.1

Expected behavior

@RefreshScope
@Bean( initMethod = "start", destroyMethod = "destroy" )
public XxlJobSpringExecutor xxlJobExecutor() {
    logger.info( ">>>>>>>>>>> xxl-job config init." );
    XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
    xxlJobSpringExecutor.setAdminAddresses( adminAddresses );
    // todo 版本冲突
    xxlJobSpringExecutor.setAppName( appName );
    xxlJobSpringExecutor.setIp( ip );
    xxlJobSpringExecutor.setPort( port );
    xxlJobSpringExecutor.setAccessToken( accessToken );
    xxlJobSpringExecutor.setLogPath( logPath );
    xxlJobSpringExecutor.setLogRetentionDays( logRetentionDays );

    return xxlJobSpringExecutor;
}
通过@RefreshScope注解实现配置中心的动态更新配置

Actual behavior

xxljob服务没有启动

Steps to reproduce the behavior

@RefreshScope @Configuration public class XxlJobConfig { private Logger logger = LoggerFactory.getLogger( XxlJobConfig.class );

@Value( "${xxl.job.admin.addresses}" )
private String adminAddresses;

@Value( "${xxl.job.executor.appname}" )
private String appName;

@Value( "${xxl.job.executor.ip}" )
private String ip;

@Value( "${xxl.job.executor.port}" )
private int port;

@Value( "${xxl.job.accessToken}" )
private String accessToken;

@Value( "${xxl.job.executor.logpath}" )
private String logPath;

@Value( "${xxl.job.executor.logretentiondays}" )
private int logRetentionDays;

@RefreshScope
@Bean( initMethod = "start", destroyMethod = "destroy" )
public XxlJobSpringExecutor xxlJobExecutor() {
    logger.info( ">>>>>>>>>>> xxl-job config init." );
    XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
    xxlJobSpringExecutor.setAdminAddresses( adminAddresses );
    // todo 版本冲突
    xxlJobSpringExecutor.setAppName( appName );
    xxlJobSpringExecutor.setIp( ip );
    xxlJobSpringExecutor.setPort( port );
    xxlJobSpringExecutor.setAccessToken( accessToken );
    xxlJobSpringExecutor.setLogPath( logPath );
    xxlJobSpringExecutor.setLogRetentionDays( logRetentionDays );

    return xxlJobSpringExecutor;
}

}

Other information

fraser-in-school commented 2 years ago

我们也用的这个版本,这个问题也出现了。后面采取的是配置写到一个配置类里,这个Config 类提供get方法给 Executor 类使用。

huanggenji commented 1 year ago

我测试了一下 在最新的2.4.0版本依然没有修复

luzhichao commented 8 months ago

我们也用的这个版本,这个问题也出现了。后面采取的是配置写到一个配置类里,这个Config 类提供get方法给 Executor 类使用。

能具体说说吗