Spring Boot内置的一些工具类】的更多相关文章

学习Java的人,或者开发很多项目,都需要使用到Spring 这个框架,这个框架对于java程序员来说.学好spring 就不怕找不到工作.我们时常会写一些工具类,但是有些时候 我们不清楚,我们些的工具类,是否稳定,可靠.对于有看spring 源码习惯的人,其实,spring框架本身自带了很多工具类,其实,我有一个想法,就是想把一些常用的方法,从spring 整理整理出来,然后编译成jar包,因为有些时候,项目并不需要引用所有jar包进入的.这边整理了一些spring 常用的类,共大家参照: s…
一.概念 1.事件监听的流程 步骤一.自定义事件,一般是继承ApplicationEvent抽象类 步骤二.定义事件监听器,一般是实现ApplicationListener接口 步骤三.启动时,需要将监听器加入到Spring容器中 步骤四.发布事件 对于配置监听器的方式[即第三步] 方式一.app.addListeners(new MyApplicationListener());添加监听器 方式二.把监听器使用纳入Spring配置中管理如使用@Component标注 方式三.再applicat…
Spring boot 内置tomcat禁止不安全HTTP方法 在tomcat的web.xml中可以配置如下内容,让tomcat禁止不安全的HTTP方法 <security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> <http-method>PUT</http-method> <http-method>DELETE</htt…
spring boot 的相关404页面配置都是针对项目路径下的(如果配置了 context-path) 在context-path不为空的情况下,如果访问路径不带context-path,这时候会显示空白页面或者是tomcat默认404页面   这时候如何自定义内置tomcat的404页面呢?   查看tomcat错误页面的实现源码org.apache.catalina.valves.ErrorReportValue: report方法中先查找是否注册了错误页面,默认情况未注册任何错误页面,然…
目录 1.问题 2.1. 为什么需要使用这个/tmp/tomcat*? 2.2.那个 /tmp/tomcat* 目录为什么不存在? 三.解决办法 修改 springboot 配置,不要在/tmp 下创建目录 修改 清理 /tmp 下面的文件的机制 四.spring boot 官方解答 1.问题 在过年后,部分运营人员反应说运营后台上传不了图片,然后查看日志,发现报错内容是/tmp/tomcat* 目录不存在. 环境: spring boot 1.5.15 Centos7.6(aliyun) 2.…
Spring Boot默认支持Tomcat/Jetty/Undertow作为底层容器.在之前实战相关的文章中,可以看到引入spring-boot-starter-web就默认使用tomcat容器,这是为什么呢? 实际通过该starter的pom.xml文件可以得到答案:其引入的就是tomcat容器. 下面分三部分内容解析Tomcat容器配置 一.自动配置原理 关于自动配置的原理,前面几篇文章已经有详细的描述,这里将容器自动配置与其他配置的不同点. 1.自动配置的类而不是直接与Tomcat相关的名…
1-添加maven依赖 2-添加redis配置 3-工具类 1-添加maven依赖 实际上是封装了jedis <!-- redis 依赖--> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>1.8.7.RELEASE</version> &l…
启用定时任务 @SpringBootApplication @EnableScheduling // 启动类添加 @EnableScheduling 注解 public class ScheduleDemoApplication { public static void main(String[] args) { SpringApplication.run(ScheduleDemoApplication.class, args); } } 新增定时任务类 @Component // 类上添加 @…
#配置内置tomcat的访问日志server.tomcat.accesslog.buffered=trueserver.tomcat.accesslog.directory=/home/hygw/logsserver.tomcat.accesslog.enabled=trueserver.tomcat.accesslog.file-date-format=.yyyy-MM-ddserver.undertow.accesslog.pattern =%h %l %u %t "%r" %s…
Spring 注解(二)注解工具类 AnnotationUtils 和 AnnotatedElementUtils Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) Spring 注解系列文章: Spring 注解(一)Spring 注解编程模型 Spring 注解(二)注解工具类 AnnotationUtils 和 AnnotatedElementUtils 首先回顾一下 AnnotationUtils 和 Annot…