springcloud工作笔记099---springboot集成netty,进行线程管理,socket通讯

这篇博客介绍了如何在SpringBoot应用中集成Netty,用于实现Socket通信。首先,展示了添加Netty依赖,接着通过配置ServletComponentScan注解使SpringBoot能够扫描到Netty的监听器。然后,创建了NettyServerListener监听器,当应用启动时启动Netty服务。服务器端通过ServerBootstrap配置并启动Netty,包含端口设置、日志记录和处理器初始化。最后,客户端使用Bootstrap建立连接,发送并接收消息。
摘要由CSDN通过智能技术生成

技术交流QQ群【JAVA,C++,Python,.NET,BigData,AI】:170933152 

一.依赖 

<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
        </dependency>
二.server端集成netty

启动类添加@ServletComponentScan

package com.hq.alp;
 
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
 
@Sp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

添柴程序猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值