Netty框架用到了java里nio的特性,可以用来建立高性能服务器,为了了解netty的源代码,使用Intellij+maven搭建netty开发环境。
1.maven中pom.xml配置
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.26.Final</version>
</dependency>
2.java代码
package com.gyq.netty;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
/**
* Created by andrewgyq on 2015/3/22.
*/
public class NettyTest {
public static void main(String[] args) {
// EventLoop 代替原来的 ChannelFactory
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
try {