springboot
小石潭记丶
从小丘西行百二十步,隔篁竹,闻水声,如鸣珮环,心乐之。伐竹取道,下见小潭,水尤清冽。全石以为底,近岸,卷石底以出,为坻,为屿,为嵁,为岩。
展开
-
Spring Webflux简介
webflux原创 2022-07-23 12:31:25 · 1830 阅读 · 0 评论 -
Spring Webflux 响应式编程 (二) - WebFlux编程实战
第一章 Reactive Stream第1节 jdk9的响应式流就是reactive stream,也就是flow。其实和jdk8的stream没有一点关系。说白了就一个发布-订阅模式,一共只有4个接口,3个对象,非常简单清晰。什么是背压?背压是指订阅者能和发布者交互(通过代码里面的调用request和cancel方法交互),可以调节发布者发布数据的速率,解决把订阅者压垮的问题。关键在于上面例子里面的订阅关系Subscription这个接口,他有request和cancel 2个方法,用于原创 2022-03-21 18:37:04 · 3679 阅读 · 1 评论 -
Spring Webflux 响应式编程 (一) - lambda表达式与stream流编程
springboot2 已经发布,其中最亮眼的非webflux响应式编程莫属了!响应式的weblfux可以支持高吞吐量,意味着使用相同的资源可以处理更加多的请求,毫无疑问将会成为未来技术的趋势,是必学的技术!很多人都看过相关的入门教程,但看完之后总觉得很迷糊,知其然不知道其所以然直接跳到运行在jdk8上的webflux,跨度太大,迷惑是在所难免的推荐学习途径如下:先学习jdk8的lambda表达式和stream流编程,了解函数式编程的知识点和思想,接着学习jdk9的响应式流flux,理解响应原创 2022-03-21 18:35:11 · 1258 阅读 · 0 评论 -
@ConditionalOnClass
FeignAutoConfiguration// the following configuration is for alternate feign clients if // ribbon is not on the class path. // see corresponding configurations in FeignRibbonClientAutoConfiguration // for load balanced ribbon clients. @Configuration.原创 2021-11-23 15:24:09 · 1775 阅读 · 1 评论 -
Springboot查询修改数据未更新问题处理
@GetMapping("/get")public Student1 get() { Optional<Student1> byMobile = studentRepository.findByMobile("19912345678"); byMobile.get().setAge(26); studentRepository.save(byMobile.get()); return studentRepository.findByMobile("199123.原创 2021-08-30 14:34:33 · 3137 阅读 · 2 评论 -
Post请求body为list,校验里面的对象
@RequestMapping(value = "/save", method = RequestMethod.POST)@ResponseBodypublic List<SaveVideo> saveVideo(@Validated @RequestBody List<SaveVideo> video, BindingResult bindingResult) { // 省略业务代码}body的参数:[{“sysNo”:“HIKID098”,“vi...原创 2021-07-09 07:53:40 · 2124 阅读 · 1 评论 -
初识EasyExcel
1、为什么使用easyexceljava解析excel的框架有很多 poi jxl 存在问题:非常的消耗内存easyexcel 我们遇到再大的excel都不会出现内存溢出的问题 能够将一个原本3M excel文件,poi来操作将会占用内存100M,使用easyexcel降低到几MB,使用起来更加简单poi读 1、创建xsshworkbook/hssfworkbook (inputstream in) 2、读取sheet 3、拿到当前sheet所有行row ...原创 2021-07-06 08:43:46 · 469 阅读 · 0 评论 -
初识@EnableAsync @Async
项目中常会使用到异步任务去完成耗时的业务逻辑处理,今天使用的是基于springboot的@EnableAsync @Async实现异步任务。1.@Async/** * Annotation that marks a method as a candidate for <i>asynchronous</i> execution. * Can also be used at the type level, in which case all of the type's me原创 2021-07-03 16:57:24 · 266 阅读 · 1 评论 -
Mysql中AND、OR的优先级导致的实际项目问题
项目中遇到问题:使用specification理想的sql:where status=? and (enterprise_name=? or credit_code=? or (legal_person_name=? and legal_person_certificate_no=?))specification拼接的sql:where status=? and (enterprise_name=? or credit_code=? or legal_person_name=? and lega原创 2021-06-29 17:06:50 · 297 阅读 · 3 评论 -
Springboot多实例启动定时任务
1.自备springboot项目2.启动实例一,配置8080(默认的端口)原创 2021-06-08 21:32:08 · 1930 阅读 · 7 评论 -
StringRedisTemplate操作hash
package com.frank.redis.web;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.data.redis.core.StringRedisTemplate;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.ann.原创 2021-06-08 20:48:26 · 5135 阅读 · 0 评论 -
Springboot使用Specification连表多条件查询(完整demo)
目录结构:package com.frank.leftJoinQuery.entity;import com.fasterxml.jackson.annotation.JsonIgnoreProperties;import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;import javax.persistence.*;/** * @author 小石潭记 * @da原创 2021-04-26 21:39:37 · 3405 阅读 · 3 评论 -
Springboot使用Specification连表查询LEFT
大致目录机构package com.frank.leftQuery.entity;import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;import javax.persistence.*;/** * @author 小石潭记 * @date 2020/12/12 18:32 * @Description: ${todo} */@Entity@Data@A原创 2021-04-24 08:40:07 · 1442 阅读 · 2 评论 -
Centos7使用docker部署springboot项目
前言:使用vm安装好centos和网络、java8等。一.准备好springboot.jar二.将文件放入centos7的文件夹中1.使用MobaXterm_Personal_20.2(使用ip addr 查看虚拟机的ip,密码root123456,默认端口22)连接虚拟机上传文件,/home/cxb文件夹下,将文件名hello-0.0.1-SNAPSHOT.jar重命名为hello.jar2.同目录下vi DockerfileFROM java:8# VOLUME 指定了临原创 2021-04-16 22:13:45 · 638 阅读 · 0 评论 -
ApplicationContextProvider 获取bean,获取指定接口所有的实现类
@Componentpublic class ApplicationContextProvider implements ApplicationContextAware { private static ApplicationContext applicationContextSpring; @Override public synchronized void setApplicationContext(ApplicationContext applicationContext.原创 2021-03-01 10:47:01 · 3094 阅读 · 1 评论 -
SpringBoot JPA使用Specification多条件查询
public Specification<SwindleAccountEntity> exportSwindleAccountSpecification(ExportSwindleAccountRequest request) { return (root, criteriaQuery, criteriaBuilder) -> { List<Predicate> predicateList = new ArrayList<>.原创 2021-02-28 16:19:12 · 1305 阅读 · 2 评论 -
ant-design-vue 气泡自定义HTML弹窗
<span slot="manageOptionCodes" slot-scope="manageOptionCodes,record,index"> <a-popover placement="bottom"> <template slot="content"> <p v-html="popove.原创 2021-02-28 16:16:00 · 2225 阅读 · 0 评论 -
springboot通过class获取bean
@Componentpublic class ApplicationContextProvider implements ApplicationContextAware { private static ApplicationContext applicationContextSpring; @Override public synchronized void setApplicationContext(ApplicationContext applicationContext.原创 2021-02-28 16:13:49 · 4031 阅读 · 0 评论 -
springboot 使用注解加解密(时间接收转换)
package corporateform.domain;import com.fasterxml.jackson.databind.annotation.JsonDeserialize;import com.fasterxml.jackson.databind.annotation.JsonSerialize;import corporateform.serialize.AESDecryptDeserialize;import corporateform.serialize.AESEncryp.原创 2021-02-28 16:11:40 · 722 阅读 · 0 评论 -
处理feign decoder 的异常情况
import com.cmb.rum.logger.exception.BusinessException;import com.cmb.rum.logger.exception.ErrorDetail;import com.cmb.rum.logger.exception.GenericError;import feign.Response;import feign.Util;import feign.codec.ErrorDecoder;import lombok.extern.slf4j.原创 2021-02-28 16:07:12 · 3823 阅读 · 0 评论 -
SpringBoot切面访问
import com.rum.logger.exception.BusinessException;import com.corporate.info.common.domain.SubscribeSystem;import com.corporate.info.domain.InterfaceVisitRecord;import com.corporate.info.service.InterfaceVisitRecordService;import com.fasterxml.jackson..原创 2021-02-28 15:53:51 · 251 阅读 · 1 评论 -
SpringBoot JPA使用Specification多表查询LEFT JOIN
1.Studentpackage com.frank.jpaSpecification.entity;import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;import javax.persistence.*;/** * @author 小石潭记 * @date 2020/12/12 18:32 * @Description: ${todo} */@Entity原创 2020-12-12 19:40:14 · 14518 阅读 · 6 评论 -
SpringBoot JPA使用Specification多条件查询(精确查询、模糊查询、时间段查询)及分页
1.实体类Mobilepackage com.frank.jpaSpecification.entity;import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.Id;import原创 2020-12-12 18:28:26 · 4606 阅读 · 3 评论 -
从零完成vue搭建element-ui前端项目,对接后端springboot项目
1.安装环境node首先:先从nodejs.org中下载nodejs,选择对应的下载即可。双击安装,在安装界面一直Next查看安装的版本号使用淘宝NPM 镜像大家都知道国内直接使用npm 的官方镜像是非常慢的,这里推荐使用淘宝 NPM 镜像。$ npm install -g npm --registry=https://registry.npm.taobao.org这样就可以使用npm 命令来安装模块了:2.安装vue的脚手架npm inst...原创 2020-12-05 12:44:07 · 3286 阅读 · 0 评论 -
Springboot JPA使用distinct返回对象
package com.frank.jpaBatchSave.repository;import com.frank.jpaBatchSave.entity.Person;import org.springframework.data.jpa.repository.Query;import org.springframework.data.repository.PagingAndSortingRepository;import org.springframework.stereotype.Rep.原创 2020-11-29 17:00:32 · 8202 阅读 · 0 评论 -
Springboot 通过filter修改Header的值
import org.apache.tomcat.util.http.MimeHeaders;import org.springframework.boot.web.servlet.FilterRegistrationBean;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.原创 2020-11-27 22:14:05 · 4296 阅读 · 4 评论 -
Springboot项目获取所有的接口
@Autowiredprivate WebApplicationContext applicationContext;@Overridepublic List getAllUrl() { RequestMappingHandlerMapping mapping = applicationContext.getBean(RequestMappingHandlerMapping.class); // 获取url与类和方法的对应信息 Map<RequestMappingIn.原创 2020-11-27 22:07:26 · 5437 阅读 · 4 评论 -
Elasticsearch+Logstash+Kibana整合Springboot收集日志
1.ELK环境搭建参考我以前的博客:https://blog.csdn.net/qq_33371766/article/details/103322707先启动ES、Kibana2.Logstash添加日志configD:\workTool\logstash-6.3.2\config 添加test.confinput{ tcp { mode => "server" host => "192.168.75.1" port => 9061...原创 2020-11-27 21:59:35 · 2042 阅读 · 1 评论 -
Springboot使用lua脚本存储redis数据及问题
未完待续原创 2020-11-17 10:51:21 · 1165 阅读 · 0 评论 -
Springboot集成EasyExcel实现文件上传下载表格
1.使用easyexcel读取表格package com.frank.excel;import com.alibaba.excel.metadata.Sheet;import com.frank.excel.model.ModelInfo;import com.frank.excel.util.ExcelUtil;import org.springframework.beans.BeanUtils;import java.util.ArrayList;import java.util.原创 2020-10-08 09:03:44 · 1674 阅读 · 0 评论 -
SpringBoot JPA 批量插入实现,使用原生sql解决SaveAll插入慢的问题
1.项目中遇到了批量插入的操作,但是使用saveAll,数据量5000条而已,速度感人,用户体验贼差,哈哈,现在将解决方法记录一下。2.创建springboot项目3.引入pom依赖<?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"原创 2020-10-04 20:53:37 · 10909 阅读 · 1 评论 -
JPA常用方法名
通用JPA的操作对应的方法名关键字 方法命名 sql where字句 And findByNameAndPwd where name= ? and pwd =? Or findByNameOrSex where name= ? or sex=? Is,Equals findById,findByIdEquals where id= ? Between findByIdBetween where id between ? and原创 2020-09-30 14:18:49 · 597 阅读 · 0 评论 -
SpringBoot集成Security、Oauth2、JWT,实现授权(代码完整可用附数据库文件和测试文件)
目录结构:pom.xml<?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 http://maven原创 2020-07-05 22:20:36 · 3748 阅读 · 3 评论 -
Springboot使用Mapstruct拷贝对象,集成swagger2
项目需求通过feign获取第三方接口,将结果映射成dto,不过dto里面的对象的属性接收的值命名可能不规范(全是大写等,不是驼峰命令等方式),所以才会用vo来接收dto的值。如果只是对象copy,可以使用BeanUtils.copyProperties进行对象之间的属性赋值(浅拷贝)但是如果对象里面还有对象和集合之类的,这样就copy失败了,这里就可以采用Mapstruct工具类进行深拷贝。Mapstruct实现步骤1.引入相关依赖(pom.xml) <depe原创 2020-07-03 20:38:54 · 1877 阅读 · 0 评论 -
SpringBoot集成Mybatis-Plus、Druid(SQL监控)
1.创建springboot项目,先实现mybatis-plus、druid2.pom文件引入<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <de原创 2020-06-29 21:47:54 · 3688 阅读 · 0 评论 -
SpringBoot实现异步任务
一.异步和同步异步(async)是相对于同步(sync)来说的,简单理解,同步是串行的,异步是并行的。好比说,A需要从B和C两个节点获取数据第一种方式,A请求B,B返回给A数据,A再去请求C,在从C出获得数据。这种方式就是同步。另一种方式,A去请求B,不等B返回数据,就去请求C,然后等B和C准备好数据再推送给A,A同样可以拿到B和C的数据,这就是异步。注意,第二种方式B和C是同时处理A的请求的,是比第一种方式效率要高的,但是这种方式,有一个限制,就是从B和C之间要获取的数据不能有依赖关系原创 2020-06-29 21:07:47 · 4162 阅读 · 0 评论 -
Sringboot2.x整合Redis缓存,设置过期时间
目录结构:pom.xml<dependencies> <!--Spring整合redis包 --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> </depe原创 2020-06-26 22:42:35 · 1177 阅读 · 0 评论 -
Springboot使用MybatisPlus实现Cache缓存
pom.xml<?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://maven.apache.org/xsd..原创 2020-06-26 12:39:52 · 6651 阅读 · 0 评论 -
Springboot2.x使用feign自定义Decoder,Advice
1.首先实现服务提供项目********pom.xml<?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:原创 2020-06-25 21:42:08 · 7785 阅读 · 11 评论 -
SpringBoot--简单处理并发demo
目录结构:(只跟book相关的)model:package com.cxb.model;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.Id;import ...原创 2018-06-22 16:49:25 · 17815 阅读 · 3 评论
分享