jeecg中官方文档定义的执行器端口不生效,启动是他默认的10001的端口访问,每起一个应用跟xxljob服务端连接端口往后加1
查看配置类,有ip和port这两个属性,奇怪了?
查看源代码,原来ip和port没有注入到配置中去
@Configuration
@EnableConfigurationProperties({XxlJobProperties.class})
@ConditionalOnProperty(
value = {"jeecg.xxljob.enabled"},
havingValue = "true",
matchIfMissing = true
)
public class XxlJobConfiguration {
private static final Logger log = LoggerFactory.getLogger(XxlJobConfiguration.class);
@Autowired
private XxlJobProperties xxlJobProperties;
public XxlJobConfiguration() {
}
@Bean
@ConditionalOnClass
public XxlJobSpringExecutor xxlJobExecutor() {
log.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(this.xxlJobProperties.getAdminAddresses());
xxlJobSpringExecutor.setAppname(this.xxlJobProperties.getAppname());
xxlJobSpringExecutor.setAccessToken(this.xxlJobProperties.getAccessToken());
xxlJobSpringExecutor.setLogPath(this.xxlJobProperties.getLogPath());
xxlJobSpringExecutor.setLogRetentionDays(this.xxlJobProperties.getLogRetentionDays());
return xxlJobSpringExecutor;
}
}
解决办法:重写他上面的容器类注入
1.把他原生代码可以复制过来,配置换为jeecg.xxljob.lookenabled,这个可以自定义名称,然后把ip和端口注入执行器;
@Configuration
@EnableConfigurationProperties({XxlJobProperties.class})
@ConditionalOnProperty(
value = {"jeecg.xxljob.lookenabled"},
havingValue = "true",
matchIfMissing = true
)
public class XxlJobConfiguration {
@Autowired
private XxlJobProperties xxlJobProperties;
public XxlJobConfiguration() {
}
@Bean
@ConditionalOnClass
public XxlJobSpringExecutor xxlJobExecutor() {
log.info("look >>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(this.xxlJobProperties.getAdminAddresses());
xxlJobSpringExecutor.setAppname(this.xxlJobProperties.getAppname());
xxlJobSpringExecutor.setAccessToken(this.xxlJobProperties.getAccessToken());
xxlJobSpringExecutor.setLogPath(this.xxlJobProperties.getLogPath());
xxlJobSpringExecutor.setLogRetentionDays(this.xxlJobProperties.getLogRetentionDays());
xxlJobSpringExecutor.setIp(this.xxlJobProperties.getIp());
xxlJobSpringExecutor.setPort(this.xxlJobProperties.getPort());
return xxlJobSpringExecutor;
}
}
2.当然,原来的application.yml的配置修改
3.修改完后重启xxljob服务端应用和客户端应用