xxl-job 报:java.net.BindException: Address already in use: bind

news/2024/5/19 1:44:04 标签: xxl-job, java, spring, spring boot

文章目录

    • 错误信息
    • 问题定位
    • 解决

错误信息

初看的时候还以为是端口占用:Address already in use: bind,不要被错误提示蒙蔽了,实则是 xxl-job 的执行器注解 @Bean 配置的问题。

java">2020-12-29 09:24:00.494  INFO 9284,// --- [      Thread-40] com.xxl.rpc.remoting.net.Server          : >>>>>>>>>>> xxl-rpc remoting server start success, nettype = com.xxl.rpc.remoting.net.impl.netty_http.server.NettyHttpServer, port = 9991
Exception in thread "Thread-44" java.net.BindException: Address already in use: bind
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:433)
	at sun.nio.ch.Net.bind(Net.java:425)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
	at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:134)
	at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:550)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
	at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:504)
	at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:489)
	at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
	at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:248)
	at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:348)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:745)

问题定位

在低版本的 xxl-job 中, 初始化 XxlJobSpringExecutor 执行器需要在 @Bean 中加上 initMethod = "start", destroyMethod = "destroy",但是在高版本的 xxl-job(如 2.1.2)则需要删除 initMethod = "start", destroyMethod = "destroy"

报错前

java">@Bean(initMethod = "start", destroyMethod = "destroy")
public XxlJobSpringExecutor xxlJobExecutor() {
    log.info(">>>>>>>>>>> xxl-job config init.");
    XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
    xxlJobSpringExecutor.setAdminAddresses(jobProperties.getAdminAddresses());
    xxlJobSpringExecutor.setAppName(jobProperties.getAppName());
    xxlJobSpringExecutor.setPort(jobProperties.getPort());
    xxlJobSpringExecutor.setLogPath(jobProperties.getLogPath());
    xxlJobSpringExecutor.setLogRetentionDays(jobProperties.getLogRetentionDays());
    xxlJobSpringExecutor.setIp(jobProperties.getIp());
    xxlJobSpringExecutor.setAccessToken(jobProperties.getAccessToken());
    return xxlJobSpringExecutor;
}

解决

@Bean 的属性 initMethod = "start", destroyMethod = "destroy" 删除即可,代码如下:

java">@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
    log.info(">>>>>>>>>>> xxl-job config init.");
    XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
    xxlJobSpringExecutor.setAdminAddresses(jobProperties.getAdminAddresses());
    xxlJobSpringExecutor.setAppName(jobProperties.getAppName());
    xxlJobSpringExecutor.setPort(jobProperties.getPort());
    xxlJobSpringExecutor.setLogPath(jobProperties.getLogPath());
    xxlJobSpringExecutor.setLogRetentionDays(jobProperties.getLogRetentionDays());
    xxlJobSpringExecutor.setIp(jobProperties.getIp());
    xxlJobSpringExecutor.setAccessToken(jobProperties.getAccessToken());
    return xxlJobSpringExecutor;
}

http://www.niftyadmin.cn/n/1240789.html

相关文章

python正则表达式面试题_Python面试题之Python正则表达式指南

1. 正则表达式基础 1.1. 简单介绍 正则表达式并不是Python的一部分。正则表达式是用于处理字符串的强大工具,拥有自己独特的语法以及一个独立的处理引擎,效率上可能不如str自带的方法,但功能十分强大。得益于这一点,在提供了正则表…

SpringBoot 无法识别 bootstrap.yml 小绿叶问题

目录错误信息问题定位解决错误信息 问题定位 一般单独使用 Spring Boot 时,bootstrap.yml 文件一般是不会生效的,也就是没有 小绿叶 图标;如果使用了 Spring Cloud 组件 bootstrap.yml 才会生效,需要引入 spring-cloud-commons-d…

无法更新标识列 wechatid_第4章 数据更新及练习题

4-1 数据的插入&#xff08;INSERT语句的使用方法&#xff09;一、什么是INSERT创建表设置字段的DEFAULT(默认值或绑定)。在每个字段的属性里面进行设置。二、INSERT语句的基本语法INSERT INTO <表名> (列1, 列2, 列3, ……) VALUES (值1, 值2, 值3, ……);原则上&#x…

python动态爱心曲线_python处理csv数据动态显示曲线实例代码

本文研究的主要是python处理csv数据动态显示曲线&#xff0c;分享了实现代码&#xff0c;具体如下。 代码&#xff1a; # -*- coding: utf-8 -*- """ Spyder Editor This temporary script file is located here: C:\Users\user\.spyder2\.temp.py ""…

第 4 章 Nacos 集群部署

目录 Nacos 部署方式Nacos 安装Nacos 启动Nacos 验证Nacos 部署方式 官方有三种部署方式 http://ip1:port/openAPI 直连ip模式,机器挂则需要修改ip才可以使用。http://vip:port/openAPI 挂载VIP模式,直连vip即可,下面挂server真实ip,可读性不好http://nacos.com:port/open…

python笔记图片_python功能笔记——图像处理

python图像处理 from PIL import Image """打开图片""" pil_imImage.open(test1.jpg).convert(L) #打开图片&#xff0c;后跟函数功能为转变成灰色 #print(pil_im) #打印图片属性GF """改变图片大小""" #pil_im.t…

python去掉数字最后的零_[781]python去除字符串中开头|结尾|所有字母、数字

string是一个字符串常量的集合的包。 公共模块变量&#xff1a;whitespace – 包含所有空白的字符串 ascii_lowercase – 包含所有小写字母的字符串 ascii_uppercase – 一个包含所有ASCII大写字母的字符串 ascii_letters – 包含所有ASCII字母的字符串 digits – 包含所有十进…

第 5 章 Nacos 域名 + VIP 模式进行集群部署

目录 章节回顾前置条件Nginx 配置验证本《Spring Cloud Alibaba微服务实战》专栏共 30 期,本期为第 5 期内容,查看专栏详情,猛戳:专栏详情 章节回顾 上一篇《Nacos 集群部署》讲解中,主要跟大家分享了如何构建生产级高可用 Nacos 集群部署方式,来满足大规模服务的注册与…