@Autowired 对象注入失败的问题

遇到的场景:netty 中初始化 mqtt 服务,添加处理器时,默认使用的是 new MstMqttSocketHandler() 返回处理器。if (isMqttRequest(msgBody)) { pipeline.addLast("mqttDecoder", new MqttDecoder()) .addLast(MqttEncoder.

- 阅读全文 -

Intellij IDE 2022.3.1 Community 社区版本无法使 properties 文件自动完成配置项

之前用的是 2022.2.1 版本的,发现有 3.1 新版本就不自觉地升级了。然后看到 spring boot 视频教程里在 application.properties 文件里添加配置时是由提示和自动完成的。他那个应该是 Ultimate 版本,而我使用的时 Community 版本,想着再怎么区别基本的需求应该是可以满足的吧。一开始在 IDE 的插件库里找 spring 相关的插件,只发现一个

- 阅读全文 -

spring boot 2.7.7 学习问题集

thymeleaf 引入后请求返回的是字符串而非 html 模板页面先引入 thymeleaf starter:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactI

- 阅读全文 -

Java 创建 List 常用方式

找了一下,Java快速创建List常用几种方式 - CSDN 最全,这边做一个摘录。/* new 方法*/ List<String> list = new ArrayList<>(); list.add("Hello"); list.add("World"); /* Arrays工具类 */ List<String> l

- 阅读全文 -

springboot 中关闭 netty channel 连接的方法

在学习 netty 建立 tcp 通讯连接时,不同情况下收集了多个关闭 channel 的方法#1 ctx.writeAndFlush("timeout").addListener(ChannelFutureListener.CLOSE_ON_FAILURE); #2 ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(Ch

- 阅读全文 -

Spring Actuator info 为空或 {}

直接上解决方法:application.properties# 2.6 以后默认为 false 隐藏 info 信息,需要开启 management.info.env.enabled=true或 application.ymlmanagement: info: env: enabled: true重启就可以看到了转自:关于Spring Actuator info为空或{}

- 阅读全文 -

spring boot @Value 注解获取不到 properties 或 yml 定义的值

之前也是看过、用过 @Value 来绑定配置文件中定义的属性值的。通过百度完善了部分拼图,除了 @Value 定义属性外,还需要对使用的类添加 @Component 以便类能够被扫描到。测试用例来自 netty writing-a-discard-server demo:public class DiscardServer { private int port;

- 阅读全文 -