jeecg中定义执行器的端口号不生效

本文解决Jeecg框架中XXL-Job执行器端口未生效的问题,通过自定义配置类及修改YAML配置文件实现端口自定义设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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服务端应用和客户端应用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值