日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

Xxl-job 提示端口占用的解決辦法

來源網絡

錯誤信息

初看的時候還以為是端口占用: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)
12345678910111213141516171819202122

問題定位

在低版本的 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;
}
12345678910111213

解決

把 @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;

后臺私信回復 1024 免費領取 SpringCloud、SpringBoot,微信小程序、Java面試、數據結構、算法等全套視頻資料。

分享到:
標簽:Xxl job
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定