xxl-job 報:java.net.BindException: Address already in use: bind
錯誤資訊
初看的時候還以為是埠占用:Address already in use: bind
,不要被錯誤提示矇蔽了,實則是 xxl-job
的執行器註解 @Bean
配置的問題。
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"
報錯前
@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"
刪除即可,程式碼如下:
@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;
}
相關文章
- 解決ProtocolHandler ["ajp-nio-8009"] java.net.BindException: Address already in use: bind問題ProtocolJavaIndexException
- 解決 eclipse出現 Address already in use: bindEclipse
- 解決nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)NginxAI
- Redis 啟動報錯Address already in useRedis
- bind (ERROR 502): bind(0.0.0.0:8811) failed. Error: Address already in use [98] (埠被佔用)ErrorAI
- efcore This MySqlConnection is already in useMySql
- mysql bind_address如何配置多個地址 mysql bind-address選項MySql
- kafka java.rmi.server.ExportException: Port already in useKafkaJavaServerExportException
- 重啟docker服務後,容器啟動報錯:Error response from daemon: id already in useDockerError
- [Vue warn]: The data property "dialogVisible" is already declared as a prop. Use prop default valueVue
- python3 tkinter報錯:_tkinter.TclError: cannot use geometry manager pack inside . which already has slaves managed by gridPythonErrorIDE
- Several ports (8005, 8080) required by Tomcatv9.0 Server at localhost are already in use.Tomcat解決方案UITomcatServerlocalhost
- Linux虛擬機器配置IP時提示:determining ip information for ip xxx.xxx.xxx.xxx address is alreadyLinux虛擬機ORM
- bind-address如果是127.0.0.1,mysql只接受localhost,不接受遠端連線127.0.0.1MySqllocalhost
- 奇怪報錯資訊“db already exists with different case already have”解決方法
- 力扣刷題對heap-use-after-free on address錯誤原因之一猜想力扣
- 錯誤: 代理丟擲異常錯誤: java.rmi.server.ExportException: Port already in use: 1099;JavaServerExportException
- git使用報錯fatal: remote origin already exists.GitREM
- already opened by ClassLoader
- django資料庫同步時報錯“Table 'XXX' already exists”Django資料庫
- Xxl-job安裝部署以及SpringBoot整合Xxl-job使用Spring Boot
- [LeetCode] Validate IP AddressLeetCode
- Window中安裝gitblit時,IP地址或埠衝突,提示Cannot assign requested address: bind的詳細解決方法Git
- 【轉載】Kano Model — Ways to use it and NOT use it
- 啟動tomcat時 錯誤: 代理丟擲異常 : java.rmi.server.ExportException: Port already in use: 1099的解決辦法TomcatJavaServerExportException
- Helm部署xxl-job
- Redo Byte Address (RBA)(轉)
- nginx useNginx
- xxl-job心跳機制
- Spring Boot 整合 xxl-jobSpring Boot
- ORA-00130: invalid listener address
- cluster-wide IP address managementIDE
- Be better to use NPMNPM
- WireGuard Use Notes
- plsql use skillsSQL
- JavaScript bind()JavaScript
- warning: already initialized constant FileUtils::VERSIONZed
- vagrant up 啟動報錯 Stderr: VBoxManage.exe: error: A NAT rule of this name already existsError