标签:erb ESS new event oid serve rap oev 加载
package com.cxy.netty.controller; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import java.net.InetSocketAddress; @Component public class NettyServer { private int port; public int getPort() { return port; } public void setPort(int port) { this.port = port; } public NettyServer(int port) { this.port = port; } public void start() throws Exception { System.out.println("启动记载netty"); EventLoopGroup boss = new NioEventLoopGroup(); EventLoopGroup work = new NioEventLoopGroup(); ServerBootstrap b = new ServerBootstrap(); b.group(boss,work) .channel(NioServerSocketChannel.class) .localAddress(new InetSocketAddress(port)) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast(new EchoServerHandler()); } }); System.out.println("启动加载netty2"); ChannelFuture channelFuturef = b.bind().sync(); if (channelFuturef.isSuccess()){ System.out.println("启动成功"); } } }
可以看到这个地方报错,笔者以为是idea的问题,所以强行启动,也还是报错,
仔细阅读了下,错误:
Could not autowire. No beans of ‘int‘ type found. less... (Ctrl+F1) Checks autowiring problems in a bean class.
这个bean无法被注入,代表这个bean是被spring管理的,然后post无法找到,
这个bean初始化的时候需要传入参数,所有spring是无法找到这个参数,所以报了这个错,
那么解决方法:首先,看你这个bean是否想被spring管理,如果不想,那么就就行将注解除去就好如果想被管理,那么就可以额加上,然后添加这个值
标签:erb ESS new event oid serve rap oev 加载
原文地址:https://www.cnblogs.com/xiufengchen/p/11919349.html