Loading

龙行博客

“后端“

后端相关

记录MyBatis常用的几种写法

循环容器的标签forEach item:集合中元素迭代时的别名, index:集合中元素迭代时的索引 open:常用语where语句中,表示以什么开始,比如以'('开始 separator:表示在每次进行迭代时的分隔符, close 常用语where语句中,表示以什么结束 //mapper中我们要为这个方法传递的是一个容器,将容器中的元素一个一个的 //拼接到xml的方法中就要使用这个forEach这个标签了 public List<Entity> queryById(List<String> userids);  ...

使用Github Action将国外的Docker镜像转存到阿里云私有仓库

Docker Images Pusher 使用Github Action将国外的Docker镜像转存到阿里云私有仓库,供国内服务器使用,免费易用 支持DockerHub, gcr.io, k8s.io, quay.io, ghcr.io等任意仓库 作者:技术爬爬虾 视频教程:https://www.bilibili.com/video/BV1Zn4y19743/ 使用方式 配置阿里云 登录阿里云容器镜像服务 https://cr.console.aliyun.com/ 启用个人实例,创建一个命名空间(ALIYUN_NAME_SPACE) 访问凭证–&g...

SpringBoot-mybatis实现自定义字段填充

这只是简单哪来做个填充比如create_time,这个我一般用数据库CURRENT_TIMESTAMP. create_by这些. 更多用法,百度. package com.sckw.transport.plugin; import org.apache.ibatis.executor.Executor; import org.apache.ibatis.mapping.MappedStatement; import org.apache.ibatis.mapping.SqlCommandType; import org.apache.ibatis.p...

使用Token机制,保证请求幂等

幂等有很多方案,但是个人觉得这个最好用,来一个示例方案先 我们使用Redis保存Token令牌,引入SpringBoot,Redis,ULID相关的依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <version>2.7.0</version> </depend...

收藏一个Hyperf好用的ENUM

地址: https://github.com/lishuncoder/enums 没用过,但是收藏一波 提供两种枚举的应用,一种是对常规枚举类的加强和扩展,即枚举类扩展,继承原枚举类原生功能的基础上拓展了注解属性,出发点源自于一些枚举的值确实一致但意义却不一样的场景: tb_user.gender: 0 未知 1 男 2 女 tb_user.type: 0 普通 1 特殊类型1 2 特殊类型2 此时值确实一致,但需要的解释和描述却完全不一致,这是通过 const 常量的注解已经无法实现这个功能,或者只能将原 const 值 变为数组,这并不优雅,这时...

springboot3.0.7-redis配置记录下

配置redis一直报错,想都不用想肯定是版本原因,各种折腾终于解决 正确的配置能用版本, 记录下 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://mav...

SpringBoot注解验证的操作方法

一样的做个记录,每次找资料耗费时间 场景: 嗯! 就是. 对接收参数进行合规性校验 目前我知道的有两种方式 第一种 直接写在Controller的方法中 public HttpResult test(@NotNull(message = "缺少参数:id") Long id) 第二种: 写在实体类中 /** * @desc: 运单新增请求bean * @author: Lt * @date: 2024/3/25 17:17 */ @Setter @Getter @Accessors(chain = true) public...

SpringBoot捕获自定义message

做个记录吧,虽然到处都是 package com.driver.businessmodules.handler; import com.utils.businesscommonutils.HttpResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.web.bind.MethodArgumentNotValidException; imp...

SpringBoot+Netty TCP协议对接充电桩

只是记录下使用记录,fd和uid的绑定没有写 引入依赖 <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>4.1.22.Final</version> </dependency> 创建编码器,解码器 编码器 // 编码器 package com.example.springbootnettyserver...

maven阿里镜像配置

每次都要去找比较麻烦,挪过来自己看的😁 ▪apache mavne中央仓库 ▪https://search.maven.org/ ▪https://mvnrepository.com/ 方式一:全局配置 可以添加阿里云的镜像到maven的setting.xml配置中,这样就不需要每次在pom中,添加镜像仓库的配置,在mirrors节点下面添加子节点: <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> &...