
spring boot
zhongbai-
这个作者很懒,什么都没留下…
展开
-
谷粒学院springsecrity+权限管理
权限管理一共五张表:实体类:用户表:@Data@EqualsAndHashCode(callSuper = false)@Accessors(chain = true)@TableName("acl_user")@ApiModel(value="User对象", description="用户表")public class User implements Serializable { private static final long serialVersionUID = 1L;原创 2022-03-15 02:44:44 · 1442 阅读 · 0 评论 -
springboot集成OAuth2.0实现微信扫码登录
目录微信登录流程添加依赖:添加配置创建常量类HttpClientUtils工具类:JwtUtils:编写接口:微信登录流程当用户授权成功后,获取到微信返回的用户信息,与数据库中进行比对,如果用户存在,则直接登录并使用jwt返回token,如果用户不存在则先在数据库中添加用户信息,添加成功后返回token;添加依赖: <dependency> <groupId>io.jsonwebtoken</groupId>原创 2022-03-14 17:22:53 · 1776 阅读 · 0 评论 -
阿里云手机验证码注册(可以使用阿里云提供的测试模板,不用个人申请)
目录打开阿里云:(绑定手机号码),不用申请模板和签名手机验证码注册流程:实现流程创建springboot工程,添加依赖编写applicatioin配置文件编写controller,根据手机号发送短信编写service:测试:打开阿里云:(绑定手机号码),不用申请模板和签名手机验证码注册流程:1.客户端输入手机号码,服务端接收手机号码(加上手机号是否已经注册的判断),并生成四位数的验证码。2.将手机号和生成的验证码传到阿里云短信验证服务端3.根据阿里云服务端的返回类型判断是否发送成功4.发送成功原创 2022-03-04 11:42:12 · 3583 阅读 · 0 评论 -
springboot集成redis使用注解
redis简介:Redis是当前比较热门的NOSQL系统之一,它是一个开源的使用ANSI c语言编写的key-value存储系统(区别于MySQL的二维表格的形式存储。)。和Memcache类似,但很大程度补偿了Memcache的不足。和Memcache一样,Redis数据都是缓存在计算机内存中,不同的是,Memcache只能将数据缓存到内存中,无法自动定期写入硬盘,这就表示,一断电或重启,内存清空,数据丢失。所以Memcache的应用场景适用于缓存无需持久化的数据。而Redis不同的是它会周期性原创 2022-03-03 15:55:31 · 3643 阅读 · 0 评论 -
springboot+Elementui的上传组件使用
上传elementui组件:<el-form-item label="选择Excel"> <el-upload ref="upload" :auto-upload="false" :on-success="fileUploadSuccess" :on-error="fileUploadError" :disabled="importBtnDisabled"原创 2022-02-27 17:23:00 · 743 阅读 · 0 评论 -
EasyExcel的读写案例
为什么要使用easyExcelgitee地址:https://gitee.com/zhongbai111/EasyExcleDemo.gitava解析、生成Excel比较有名的框架有Apache poi、jxl。但他们都存在一个严重的问题就是非常的耗内存,poi有一套SAX模式的API可以一定程度的解决一些内存溢出的问题,但POI还是有一些缺陷,比如07版Excel解压缩以及解压后存储都是在内存中完成的,内存消耗依然很大。easyexcel重写了poi对07版Excel的解析,一个3M的exc原创 2022-02-26 23:05:14 · 710 阅读 · 0 评论 -
Bean无法注入,‘sqlSessionFactory‘ threw exception,‘dataSource‘ threw exception大坑
原因:配置类没有被扫描到:解决办法:异常: Error creating bean with name 'eduChapterController': Unsatisfied dependency expressed through field 'eduChapterService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean wit原创 2022-02-25 16:41:51 · 2124 阅读 · 0 评论 -
RabbitMQ安装启动以及与springboot整合
第一步安装erlang环境:下载:由于rabbitmq是erlang来写的,所以需要安装erlang环境:https://www.erlang-solutions.com/resources/download.html安装:yum -y install esl-erlang_23.0.2-1_centos_7_amd64.rpm检测erlang:erl第二步安装RabbitMQ下载:http://www.rabbitmq.com/download.html安装rabbitmq:原创 2022-02-17 16:55:11 · 1335 阅读 · 0 评论 -
springboot使用redisTemplate
第一步:创建spring boot项目导入redis相关依赖 <!-- spring data redis 依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </原创 2022-01-13 16:20:31 · 965 阅读 · 0 评论 -
spring boot封装返回信息
创建返回的枚举类:import lombok.*;/** * @author * @date 2022/1/11 - 11:23 * 返回状态枚举 *///@Data只能在类上使用//使用lombok注解@Getter@ToString@AllArgsConstructorpublic enum RespBeanEnum { //通用状态码 SUCCESS(200,"success"), ERROR(500,"服务端异常"), //登录模块5002原创 2022-01-11 15:14:45 · 291 阅读 · 0 评论 -
org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
springboot项目启动时出现org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1报错第一步:删除application.yal,重新创建;第二步:maven工具栏先clear再install原创 2022-01-11 11:07:24 · 351 阅读 · 0 评论 -
springboot项目@CrossOrigin注解不生效
需要实现前后端项目分离,需要解决跨域问题:在springboot启动类上面添加跨域注解@CrossOrigin但是依然报错!!编写配置类:import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.web.cors.CorsConfiguration;import org.原创 2021-11-01 10:33:22 · 671 阅读 · 0 评论 -
maven聚合工程Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasour
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2021-10-28 13:48:06.381 ERROR 276 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************APPLICATION F原创 2021-10-28 13:55:47 · 358 阅读 · 0 评论 -
聚合工程中@SpringBootTest注解报错
注意父工程引入的spring-boot-starter-test依赖的工作空间:其他模块无法使用,删除scope!!重新加载,就可以了原创 2021-10-28 10:28:58 · 271 阅读 · 0 评论 -
springboot整合⾕歌开源缓存框架Guava Cache使用
Guava Cache使用Guava Cache:⾕歌开源缓存框架Guava Cache使用使用压测⼯具Jmeter5.x进行接口压力测试:压测⼯具本地快速安装Jmeter5.x新增聚合报告:线程组->添加->监听器->聚合报告(Aggregate Report)Guava Cache:⾕歌开源缓存框架Guava Cache是在内存中缓存数据,相比较于数据库或redis存储,访问内存中的数据会更加高效。Guava官网介绍,下面的这几种情况可以考虑使用Guava Cache:愿意消耗原创 2021-08-15 10:36:49 · 725 阅读 · 2 评论 -
SpringBoot开启跨域配置
什么是浏览器跨域和springboot怎么解决跨域:浏览器同源策略 1995年,同源政策由 Netscape 公司引⼊浏览器。⽬前,所有浏览器都实 ⾏这个政策。最初,它的含义是指,A⽹⻚设置的 Cookie,B⽹⻚不能打开,除⾮这两个⽹⻚"同 源"。所谓"同源"指的是"三个相同协议相同 http https域名相同 www.xdclass.net端⼝相同 80 81⼀句话:浏览器从⼀个域名的⽹⻚去请求另⼀个域名的资源时,域名、端⼝、协议任⼀不同,都是跨域浏览器控制台跨域提示:No '原创 2021-08-15 10:05:47 · 1557 阅读 · 0 评论 -
idea中springboot项目实现热部署
第一步:在pom.xml中引入相关依赖,以及插件相关配置:<!--热部署相关--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>原创 2021-08-12 15:20:14 · 84 阅读 · 0 评论 -
SpringBoot博客项目
SpringBoot博客项目项目背景项目搭建创建一个springBoot项目添加相关依赖pom.xml:添加配置文件异常处理:例如404,500,错误信息提示等界面设置1.自定义错误界面:2.全局的异常处理类ControllerExceptionHandler :日志处理信息包含:引入之前做好的静态界面:登录拦截器:实体类关系:Mybatis逆向工程:实体类:管理员主要功能实现:登录注销功能部分逻辑代码:博客内容管理的增删查改:列表实现项目背景项目原型是李仁密老师的作品,具体的教学视频来自b站https原创 2021-08-09 11:05:36 · 663 阅读 · 0 评论 -
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
原因:springboot项目多项目中,该模块缺少数据库配置信息:在该模块配置类中加上数据库配置信息:# mysql数据库连接spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring.datasource.url=jdbc:mysql://localhost:3306/musicdb?serverTimezone=GMT%2B8spring.datasource.username=rootspring.datasour.原创 2021-06-15 18:57:40 · 97 阅读 · 0 评论 -
spring boot集成阿里云OSS上传文件
第一步:开通阿里云OSS服务,创建Bucket,获取id和密钥第二步:根据官方文档编写上传代码1.新建maven项目添加依赖:<!-- 阿里云oss依赖 --> <dependency> <groupId>com.aliyun.oss</groupId> <artifactId>aliyun-sdk-oss</artifactId> </dependency> <!-- 日期工具栏依赖 --&g原创 2021-06-15 18:54:30 · 2025 阅读 · 9 评论 -
[Vue warn]: Error in render: “TypeError: Cannot read property ‘name‘ of undefined“
注意检查后端接口返回的对象别名我的错误:后端返回eduTeacher: return R.ok().data("eduTeacher",eduTeacher);前端用teacher接收则会报错,找不到属性name等将后端返回改为: return R.ok().data("teacher",eduTeacher);没有报错。...原创 2021-06-15 11:05:45 · 258 阅读 · 2 评论 -
springboot-vue增删改功能实现步骤
第一步:写后端接口 @ApiOperation(value = "讲师添加") @PostMapping("addteacher") public R addTeacher(@RequestBody EduTeacher eduTeacher){ boolean save = eduTeacherService.save(eduTeacher); if(save){ return R.ok(); }else{原创 2021-06-15 09:44:35 · 1104 阅读 · 3 评论 -
springboot的logback统一日志
一、日志1、配置日志级别日志记录器(Logger)的行为是分等级的。如下表所示:分为:OFF、FATAL、ERROR、WARN、INFO、DEBUG、ALL默认情况下,spring boot从控制台打印出来的日志级别只有INFO及以上级别,可以配置日志级别# 设置日志级别logging.level.root=WAR这种方式只能将日志打印在控制台上二、Logback日志spring boot内部使用Logback作为日志实现的框架。Logback和log4j非常相似,如果你对log4j很原创 2021-06-02 13:08:36 · 231 阅读 · 1 评论 -
springboot异常处理的三种方式
制造异常:报500错误。在大量的代码中很难找到错误统一异常处理:添加异常处理方法GlobalExceptionHandler.java中添加@ExceptionHandler(ArithmeticException.class)@ResponseBodypublic R error(ArithmeticException e){ e.printStackTrace(); return R.error().message("执行了自定义异常");}报错异常:在大型项目中,可对多种异原创 2021-06-01 18:37:40 · 2754 阅读 · 2 评论 -
springBoot集成mybatisplus添加操作,字段的自动填充实现
第一步:在属性上添加注解: @TableField(fill = FieldFill.INSERT)//添加时自动填充时间注解 @TableField(fill = FieldFill.INSERT_UPDATE)//修改时自动填充时间多用于自动填充实体类时间属性: @ApiModelProperty(value = "创建时间") @TableField(fill = FieldFill.INSERT)//添加时自动填充时间注解 private Date gmtCreate;原创 2021-06-01 17:28:45 · 381 阅读 · 0 评论 -
springboot集成swagger报错:Unable to infer base url.
访问:http://localhost:8001/swagger-ui.html报错内容:Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if th原创 2021-06-01 13:12:28 · 699 阅读 · 1 评论 -
springboot集成redis
简介:在springboot2.x之后,原来使用的jedis被替换为lettucejedis:采用直连,多个线程操作不安全,如果想要避免不安全,使用Jedis pool连接池;BIO模式lettuce:采用netty,实例可以在多个线程中进行共享,不存在线程不安全的情况,可以减少线程数据。NIO模式1.引入依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>原创 2021-03-26 20:22:49 · 304 阅读 · 0 评论 -
[16468] 26 Mar 17:34:58.549 # Creating Server TCP listening socket *:6379: bind: No error
原创 2021-03-26 17:36:57 · 124 阅读 · 0 评论 -
springboot邮件任务
第一步:引入pom依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId></dependency>查看一下配置类,可以注入那些信息3、配置文件:spring.mail.username=xxxxxxxx@qq.comspring.mail.passw原创 2021-03-24 16:32:05 · 137 阅读 · 0 评论 -
springboot的定时任务
定时任务项目开发中经常需要执行一些定时任务,比如需要在每天凌晨的时候,分析一次前一天的日志信息,Spring为我们提供了异步执行任务调度的方式,提供了两个接口。TaskExecutor接口TaskScheduler接口两个注解:@EnableScheduling@Scheduled...原创 2021-03-24 16:05:50 · 313 阅读 · 0 评论 -
SpringBoot的异步任务开启
SpringBoot异步任务创建一个service包创建一个类AsyncService先模拟同步等待的情况@Servicepublic class AsyncService { public void hello(){ try { Thread.sleep(5000);//停止五秒 } catch (InterruptedException e) { e.printStackTrace(); }原创 2021-03-24 15:52:38 · 196 阅读 · 0 评论 -
搭建个人博客需要用到的插件
编辑器 Markdown https://pandao.github.io/editor.md/内容排版 typo.css https://github.com/sofish/typo.css动画 animate.csshttps://daneden.github.io/animate.css/代码高亮 prismhttps://github.com/PrismJS/prism目录生成 Tocbothttps://tscanlin.github.io/tocbot/滚动侦测 wa原创 2021-03-03 16:37:28 · 246 阅读 · 2 评论 -
springBoot整合mybatis–plus
第一步:导入依赖<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>com.baomidou</groupId>原创 2021-02-28 15:14:47 · 162 阅读 · 0 评论 -
springboot-vue小案例
GitHub地址:https://github.com/zhongbaigeng/springboot-vue第一步:创建springboot项目以及一个vue的elementui项目vue的elementui项目创建可以参考:https://blog.youkuaiyun.com/sjgllllll/article/details/112726237第二步:springboot项目环境搭建(提供接口)GitHub地址:https://github.com/zhongbaigeng/springboot原创 2021-02-26 15:03:22 · 370 阅读 · 0 评论 -
SpringBoot集成Swagger
Swagger号称世界上最流行的API框架Restful Api 文档在线自动生成器 => API 文档 与API 定义同步更新直接运行,在线测试API支持多种语言 (如:Java,PHP等)官网:https://swagger.io/SpringBoot集成Swagger => springfox,两个jar包Springfox-swagger2swagger-springmvc使用Swagger要求:jdk 1.8 + 否则swagger2无法运行步骤:1、新原创 2021-02-24 10:46:30 · 107 阅读 · 0 评论 -
thymeleaf整合shiro
第一步:先在pom.xml加入thymeleaf和shiro的依赖<dependency> <groupId>com.github.theborakompanioni</groupId> <artifactId>thymeleaf-extras-shiro</artifactId> <version>1.2.1</version></dependency>第二步:在ShiroConfig原创 2021-02-21 22:22:18 · 214 阅读 · 0 评论 -
springboot集合shiro
第一步导入依赖: <dependencies> <!-- shiro三大对象 subject:用户 securityManager:管理所有用户 Realm:连接数据库 --> <!-- springboot与shiro的依赖 --> <dependency> <groupId原创 2021-02-21 22:19:12 · 121 阅读 · 0 评论 -
yml以及properties的数据库配置
application.ymlserver: port: 8081spring: datasource: password: 123456 url: jdbc:mysql://localhost:3306/jsptest?useSSL=false&serverTimezone=UTC driver-class-name: com.mysql.cj.jdbc.Driver username: root type: com.alibaba.druid.原创 2021-02-20 10:59:16 · 981 阅读 · 0 评论 -
Shiro的快速开始
官网地址:https://shiro.apache.org/第一步导入依赖:<dependencies> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.4.1</version>原创 2021-02-17 09:47:43 · 163 阅读 · 1 评论 -
SpringBoot整合SpringSecurity案例
第一步:导入依赖 <dependencies> <!-- https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity4 --> <dependency> <groupId>org.thymeleaf.extras</groupId> <artif原创 2021-02-14 10:14:21 · 107 阅读 · 0 评论