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;
}
}
1条答案
按热度按时间g52tjvyc1#
我们也用的这个版本,这个问题也出现了。后面采取的是配置写到一个配置类里,这个Config 类提供get方法给 Executor 类使用。