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管理,如果不想,那么就就行将注解除去就好如果想被管理,那么就可以额加上,然后添加这个值

Could not autowire. No beans of 'int' type found. less... (Ctrl+F1) Checks autowiring problems in a bean class.的更多相关文章

  1. Could not autowire. No beans of 'TbItemMapper' type found. less... (Ctrl+F1) Checks autowiring prob

    Intellij Idea开发工具在@Autowired或者@Resource注入XxxMapper接口时报如下错误: Could not autowire. No beans of 'TbItemM ...

  2. Could not autowire. No beans of 'TbAssetsMapper' type found. less... (Ctrl+F1) Inspection info:Checks autowiring problems in a bean class.

    报错:Could not autowire. No beans of 'TbAssetsMapper' type found. less... (Ctrl+F1) Inspection info:Ch ...

  3. IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示

    1.问题描述 在Idea的spring工程里,经常会遇到Could not autowire. No beans of 'xxxx' type found的错误提示.但程序的编译和运行都是没有问题的, ...

  4. Could not autowire. No beans of 'xxxx' type found的错误

    在Idea的spring工程里,经常会遇到Could not autowire. No beans of 'xxxx' type found的错误提示.但程序的编译和运行都是没有问题的,这个错误提示并 ...

  5. IntelliJ Idea设置Could not autowire. No beans of 'xxx' type found

    1.问题描述 在Idea的spring工程里,经常会遇到Could not autowire. No beans of ‘xxxx’ type found的错误提示.但程序的编译和运行都是没有问题的, ...

  6. IntelliJ Idea解决Could not autowire. No beans of 'xxxx' type found的错误提示

    本文转自:http://blog.csdn.net/u012453843/article/details/54906905 1.问题描述 在Idea的spring工程里,经常会遇到Could not ...

  7. 【转】IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示

    1.问题描述 在Idea的spring工程里,经常会遇到Could not autowire. No beans of 'xxxx' type found的错误提示.但程序的编译和运行都是没有问题的, ...

  8. SpringBoot注入Mapper提示Could not autowire. No beans of 'xxxMapper' type found错误

    通过用Mabatis的逆向工程生成的Entity和Mapper.在Service层注入的时候一直提示Could not autowire. No beans of 'xxxMapper' type f ...

  9. IDEACould not autowire. No beans of 'xxxMapper' type found.

    作为一名刚开始使用idea的新手,最近在使用maven+springMVC框架时遇到了这样一个问题:Could not autowire. No beans of 'xxxMapper' type f ...

随机推荐

  1. c# HttpListener 使用

    与 IIS 上发布网站相比,使用 HttpListener 编程的程序更加轻量化,易于发布和更新.配合 Thread 或 Task 类也可满足一定的并发. https://docs.microsoft ...

  2. jsp与httpservlet的微小区别

    2015-8 jsp与httpservlet的微小区别: jsp默认支持会话,httpservlet默认不支持会话:jsp: 可以直接通过session引用httpservlet对象httpservl ...

  3. Caused by: java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider

    问题现象:今天部署代码的时候发现,在beta环境可以正常部署,但是到了test环境就一直不成功,我以为是环境问题,就重新部署,但是没效,看了看日志发现问题是:Caused by: java.lang. ...

  4. Paint的Gradient的用法(转)

    转自:https://www.jianshu.com/p/02b02c1696b2 Paint的Gradient的用法 嗯哼嗯哼嗯哼嗯哼 关注 2017.07.04 15:45* 字数 173 阅读 ...

  5. C++ 使用老牌库xzip & unzip对文件进行压缩解压

    原文链接 https://www.codeproject.com/Articles/7530/Zip-Utils-clean-elegant-simple-C-Win https://www.code ...

  6. Concurrent - 多线程

    原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11426916.html Java中有几种方法可以实现一个线程? 继承Thread类(不支持多继承) 实 ...

  7. localstorage sessionstorage和cookie的区别

    基本概念 cookie:是网景公司的前雇员在1993年发明.它的主要用于保存登陆信息,比如登陆某个网站市场可以看到'记住密码’,这就是通过在cookie中存入一段辨别用户身份的数据来实现的. sess ...

  8. 【leetcode】927. Three Equal Parts

    题目如下: Given an array A of 0s and 1s, divide the array into 3 non-empty parts such that all of these ...

  9. mui.min.js:7 Uncaught DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load

    mui框架做的微信公众号网页,在上传数据的时候报了这个错,async: true,//将false改为true就可以了 https://blog.csdn.net/liuzp111/article/d ...

  10. Oracle数据库中,sql中(+)(-)的含义

    SELECT *FROM TABLE1 A,TABLE2 B WHERE A.ID(+)=B.ID; 右连接=RIGHT JOIN SELECT *FROM TABLE1 A,TABLE2 B WHE ...