xxl-job简约安装与使用

XXL-JOB是一个轻量级分布式任务调度平台,其核心设计目标是开发迅速、学习简单、轻量级、易扩展。

下载源码

通过命令

git clone https://github.com/xuxueli/xxl-job/

阅读更多   2019/9/2 posted in  SpringBoot

Spring Boot Admin

Spring Boot Admin 是一个管理和监控 Spring Boot 应用程序的开源软件。每个应用都认为是一个客户端,通过HTTP或者使用注册中心注册到 Admin server中进行展示,Spring Boot Admin UI 部分使用 AngularJs 将数据展示在前端。
Spring Boot Admin 是一个针对spring-boot 的 actuator 接口进行UI美化封装的监控工具。他可以:在列表中浏览所有被监控 spring-boot项目的基本信息,详细的Health信息、内存信息、JVM信息、垃圾回收信息、各种配置信息(比如数据源、缓存列表和命中率)等,还可以直接修改logger的level。

阅读更多   2019/8/7 posted in  SpringBoot

SpringBoot自定义错误

@ControllerAdvice 可以处理应用级别的异常,有一些容器级别的错误就处理不了,例如 Filter 中抛出异常,使用@ControllerAdvice 定义的全局异常处理机制就无法处理。
可以增加一个配置类,这个类继承 DefaultErrorAttributes 即可。如果想完全自定义错误机制(指json和html),新建一个controller,继承BasicErrorController即可

2019/7/8 posted in  SpringBoot

API 最佳实践

初衷

旨在对api规划之初做出约定,使研发成员建立默契,提升研发品质和效率

协议

使用 https 协议最佳

阅读更多   2019/5/9 posted in  SpringBoot

SpringBoot的Controller接收多个实体

Controller接收多个实体,网上有很多方法,我使用的是Map参数这种方法,在方法的参数里面写:@RequestBody Map map
然后在方法体里面得到前端从传入的两个实体:

ClassA classa = JSON.parseObject(JSON.toJSONString(map.get("classa")), ClassA.class);
        ClassB classb = JSON.parseObject(JSON.toJSONString(map.get("classb")), ClassB.class);

完成!

2019/2/19 posted in  SpringBoot

SpringBoot2.0 设置文件上传大小限制

在SpringBoot2.0之前,使用的是

spring:
  http:
   multipart:
    max-file-size: 100MB 
    max-request-size: 1000MB

在SpringBoot2.0后是

spring:
  servlet:
    multipart:
      max-file-size: 1024MB
      max-request-size: 1024MB
2019/1/4 posted in  SpringBoot

An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments to which they apply

今天测试接口的时候,出现了这个错误

An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments to which they apply

阅读更多   2018/11/28 posted in  SpringBoot

Listener, Servlet, Filter和Interceptor

  1. 监听器Listener

    Listener可以监听web服务中某一个事件操作,并触发注册的回调函数。通俗的语言就是在applicationsession,request三个对象创建/消亡或者增删改属性时,自动执行代码的功能组件。

阅读更多   2018/11/15 posted in  SpringBoot

MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk

今天使用SpringBoot操作Redis的时候,报错

io.lettuce.core.RedisCommandExecutionException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

大意为:
redis.exceptions。MISCONF Redis配置为保存RDB快照,但目前无法在磁盘上持久保存。可以修改数据集的命令被禁用。有关错误的详细信息,请查看Redis日志。

这是由于强制停止redis快照,不能持久化引起的,

解决方案如下:

打开redis-cli

输入 config set stop-writes-on-bgsave-error no命令

解决!

2018/11/10 posted in  Redis SpringBoot

MongoTemplate 添加对象到MongoDB有_class属性的解决方法

使用SpringBoot的版本是 1.5.12.RELEASE

阅读更多   2018/5/31 posted in  SpringBoot