草庐IT

springboot-websocet

全部标签

优化SpringBoot程序启动速度

SpringBoot程序优化一、延迟初始化Bean一般在SpringBoot中都拥有很多的耗时任务,比如数据库建立连接、初始线程池的创建等等,我们可以延迟这些操作的初始化,来达到优化启动速度的目的。SpringBoot2.2版本后引入spring.main.lazy-initialization属性,配置为true会将所有Bean延迟初始化。spring:main:lazy-initialization:true二、创建扫描索引Spring5之后提供了spring-context-indexer功能,通过提前生成@ComponentScan的扫描索引,解决在类过多时导致扫描速度过慢的问题。我们

优化SpringBoot程序启动速度

SpringBoot程序优化一、延迟初始化Bean一般在SpringBoot中都拥有很多的耗时任务,比如数据库建立连接、初始线程池的创建等等,我们可以延迟这些操作的初始化,来达到优化启动速度的目的。SpringBoot2.2版本后引入spring.main.lazy-initialization属性,配置为true会将所有Bean延迟初始化。spring:main:lazy-initialization:true二、创建扫描索引Spring5之后提供了spring-context-indexer功能,通过提前生成@ComponentScan的扫描索引,解决在类过多时导致扫描速度过慢的问题。我们

Springboot对Websocket的实现

本文章是使用Springboot+WebSocket简单实现一个web界面的聊天室项目结构如下 首先在springboot项目的pom.xml中导入所需要的依赖包web、websocket以及解析JSON格式的fastjsonorg.springframework.bootspring-boot-starter-weborg.springframework.bootspring-boot-starter-tomcatprovidedcom.alibabafastjson2.0.7org.springframework.bootspring-boot-starter-websocket2.实现前

Springboot使用JustAuth完成各种第三方登陆

目录使用Gitee进行登陆1.Gitee准备工作2.编码3.建立数据表     4.自由发挥示例:使用Gitee进行登陆1.Gitee准备工作进入gitee,在设置中选择此选项 2.编码依赖 com.xkcoding.justauthjustauth-spring-boot-starter1.4.0com.alibabafastjson1.2.83配置文件justauth:#是否启用enabled:truetype:#配置各种类型的登陆GITEE:#创建的应用的client-idclient-id:xxclient-secret:xx#自己写的回调地址redirect-uri:http://1

[springboot] spring-boot-maven-plugin指定版本问题

1.pom.xml文件报如下错误:(需要指定版本)Plugin'org.springframework.boot:spring-boot-maven-plugin:'notfoundorg.springframework.bootspring-boot-maven-plugin解决方法:打开Maven本地仓库。查看/org/springframework/boot路径下的spring-boot-maven-plugin文件夹底下,是否存在与springboot的版本相对应版本号,如果存在,添加标签为自己的springboot版本(这里我的版本是2.7.5):org.springframewor

springboot实现微信小程序V3微信支付功能

springboot对接微信小程序V3微信支付功能(支付、退款、查询)1.程序开发前的准备工作,获取微信支付相关的参数1.1在application.yml文件中填写配置信息1.2获取配置文件中的参数2.在pom.xml中引入相关依赖3.实现微信支付相关方法3.1获取平台证书3.2微信支付3.3微信支付回调3.4微信退款3.5订单查询1.程序开发前的准备工作,获取微信支付相关的参数appId:小程序appidappSecret:小程序的secretmchId:商户号keyPath:商户私钥路径(apiclient_key.pem)certPath:证书路径(apiclient_cert.pem

SpringBoot:模块探究之spring-boot-dependencies

在SpringBoot开发时,我们常常会发现一个现象:即在pom文件中,加入一个新的依赖,往往不需要引入相应的版本号(如下代码块所示),就可以正常引入依赖,这其实是因为我们依赖了spring-boot-starter-parent模块的缘故!点spring-boot-starter-parent进去查看源文件会发现,spring-boot-starter-parent继承了spring-boot-dependencies!点spring-boot-dependencies进去查看源文件会发现,它在管理着相关依赖的版本。在dependencyManagement进行依赖管理,在pluginMan

Springboot 使用logback直接将日志写入Elasticsearch,再通过kibana查看

Springboot使用logback直接将日志写入Elasticsearch,再通过kibana查看正常情况下,一般组合为elk即日志会通过logstash写入es,但本文主要为轻量级项目直接利用appender写入Elasticsearch1.导入依赖dependency>groupId>com.internetitemgroupId>artifactId>logback-elasticsearch-appenderartifactId>version>1.6version>dependency>dependency>groupId>net.logstash.logbackgroupId>

springboot整合rabbitMQ

1.生产者工程pom.xml里引入依赖org.springframework.bootspring-boot-starter-amqpapplication.yml里配置基本信息spring:rabbitmq:host:localhostport:5672username:******password:******virtual-host:/test在配置类里创建交换机,队列,绑定交换机和队列packagecom.min.config;importorg.springframework.amqp.core.*;importorg.springframework.beans.factory.an

SpringBoot与MyBatis零XML配置集成和集成测试

原文地址:https://ntopic.cn/p/2023070801/源代码先行:Gitee本文介绍的完整仓库:https://gitee.com/obullxl/ntopic-bootGitHub本文介绍的完整仓库:https://github.com/obullxl/ntopic-boot背景介绍在Java众多的ORM框架里面,MyBatis是比较轻量级框架之一,既有数据表和Java对象映射功能,在SQL编写方面又不失原生SQL的特性。SpringBoot提倡使用注解代替XML配置,同样的,在集成MyBatis时也可以做到全注解化,无XML配置。相关的集成方法网上存在大量的教程,本文是个