package com.ruoyi.dataInterchange.netty.server;
|
|
import io.netty.bootstrap.ServerBootstrap;
|
import io.netty.channel.ChannelFuture;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.PostConstruct;
|
|
/**
|
* @author zhibing.pu
|
* @Date 2025/3/3 20:06
|
*/
|
@Slf4j
|
@Component
|
public class NettyStart {
|
|
@Autowired
|
private ServerBootstrap serverBootstrap;
|
|
private int nettyPort = 1000;
|
|
private ChannelFuture serverChannelFuture;
|
|
@PostConstruct
|
public void start() throws Exception {
|
log.info("Netty服务启动成功:" + nettyPort);
|
serverChannelFuture = serverBootstrap.bind(nettyPort).sync();
|
}
|
}
|