spring boot 1.x.x 到 spring boot 2.x.x 的那些变化
spring boot1 到 spring boot2的配置变化很大,迁移项目到spring boot2过程中发现以下变化
1.java 的 redis 配置添加了属性jedis
旧版
spring:
redis:
timeout: 300000
pool.max-active: 20
pool.max-idle: 5
pool.max-wait: -1
pool.min-idle: 0
新版
spring:
redis:
timeout: 300000
jedis:
pool.max-active: 20
pool.max-idle: 5
pool.max-wait: -1
pool.min-idle: 0
2.tomcat 原来的线程池@bean配置不再支持,但yaml或properties配置没变
yaml配置:
server:
tomcat:
uri-encoding: utf-8
max-threads: 1000
max-connections: 900
min-spare-threads: 100
版本1的@bean配置:
@Configuration
public class TomcatConfig {
@Bean
public EmbeddedServletContainerFactory containerFactory() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.addConnectorCustomizers((connector) -> {
Http11NioProtocol protocol = (Http11NioProtocol)connector.getProtocolHandler();
protocol.setMaxConnections(1000);
protocol.setMaxThreads(1000);
protocol.setMinSpareThreads(100);
});
return factory;
}
}
3.项目访问路径配置,版本2新加了servlet属性
旧版:
server:
port: 8089
context-path: /brieftkheal
servlet-path: /
新版:
server:
port: 8089
servlet:
context-path: /brieftkheal
path: /
4.实体类配置参数的prefix在新版本不让出现驼峰式命名,而是用‘-’分割开,如:
旧版:
@Component
@ConfigurationProperties(prefix = "ipPhone")
public class IpPhoneConfigProperties {
private String url;
private String id;
private String key;
private String pensionNumber;
private Status status;
private String ip1;
private String ip2;
private String eButlerPhoneWSUrl;
。。。。。。
public static class Status{
private String success;
private String noUser;
private String noBalance;
private String unknown;
。。。。。。
}
}
ipPhone:
url:
id:
key:
pensionNumber:
ip1:
ip2:
eButlerPhoneWSUrl:
status:
success: 0
noUser: 4
noBalance: 16
unknown: 999
新版:
@Component
@ConfigurationProperties(prefix = "ip-phone")
public class IpPhoneConfigProperties {
private String url;
private String id;
private String key;
private String pensionNumber;
private Status status;
private String ip1;
private String ip2;
private String eButlerPhoneWSUrl;
。。。。。。
public static class Status{
private String success;
private String noUser;
private String noBalance;
private String unknown;
。。。。。。
}
}
ip-phone:
url:
id:
key:
pensionNumber:
ip1:
ip2:
eButlerPhoneWSUrl:
status:
success: 0
noUser: 4
noBalance: 16
unknown: 999
5.拦截器HandlerInterceptor 在2.0.0版本中默认拦截静态资源Resource
HandlerMethod,跳过静态资源才走
HandlerMethod对象的拦截,如果用swagger做接口api,需要加判断
if(o instanceof HandlerMethod)
6.spirngboot2.0版本全面支持java8,jpa的部分方法返回类型由原来的T变成了Optional<T>,如findById,findOne等方法,如要获取实体类T,用optional.get()方法
7.RedisCacheManager类的配置变了,我目前没有找到配置方法,望指教
8.spring文件上传配置有变化
1.x版本:
spring:
http:
multipart:
max-file-size: 4MB
max-request-size: 150MB
2.x版本:
spring:
servlet:
multipart:
max-file-size: 4MB
max-request-size: 150MB
好了,目前就发现这些,欢迎补充并指出不足
spring boot 1.x.x 到 spring boot 2.x.x 的那些变化的更多相关文章
- [Spring Boot 系列] 集成maven和Spring boot的profile功能
由于项目的需要, 今天给spirng boot项目添加了profile功能.再网上搜索了一圈,也没有找到满意的参考资料,其实配置并不难,就是没有一个one stop(一站式)讲解的地方,所以有了写这篇 ...
- spring boot系列01--快速构建spring boot项目
最近的项目用spring boot 框架 借此学习了一下 这里做一下总结记录 非常便利的一个框架 它的优缺点我就不在这背书了 想了解的可以自行度娘谷歌 说一下要写什么吧 其实还真不是很清楚,只是想记录 ...
- Spring Boot系列(一) Spring Boot介绍和基础POM文件
Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置.通过 ...
- Spring Boot 2.0(二):Spring Boot 2.0尝鲜-动态 Banner
Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner,今天我们就先拿这个来尝尝鲜. 配置依赖 使用 Spring Boot 2.0 首先需要将项目依赖包替换为刚刚发 ...
- Spring Boot 2.0(三):Spring Boot 开源软件都有哪些?
2016年 Spring Boot 还没有被广泛使用,在网上查找相关开源软件的时候没有发现几个,到了现在经过2年的发展,很多互联网公司已经将 Spring Boot 搬上了生产,而使用 Spring ...
- 【转】Spring Boot 构建应用——快速构建 Spring Boot 应用
Spring Boot 简化了 Spring 应用开发,不需要配置就能运行 Spring 应用,Spring Boot 的自动配置是通过 Spring 4.x 的条件注解 @Conditional 来 ...
- Spring Boot 2.0(八):Spring Boot 集成 Memcached
Memcached 介绍 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站 ...
- Quick Guide to Microservices with Spring Boot 2.0, Eureka and Spring Cloud
https://piotrminkowski.wordpress.com/2018/04/26/quick-guide-to-microservices-with-spring-boot-2-0-eu ...
- Spring Boot初识(3)- Spring Boot整合Swagger
一.本文介绍 如果Web项目是完全前后端分离的话(我认为现在完全前后端分离已经是趋势了)一般前端和后端交互都是通过接口的,对接口入参和出参描述的文档就是Mock文档.随着接口数量的增多和参数的个数增加 ...
- spring boot (2):spring boot 打包tomcat、tomcat 部署多个项目、服务器部署项目SSL 设置(阿里云)
一.spring boot 内置tomcat配置https: 关于自签名证书可以看下上一篇 spring boot1 更详细的可以看转载 https://www.jianshu.com/p/8d4ab ...
随机推荐
- am335x在ubuntu下使用StarterWare编写裸机程序并在CCS中用Jlink调试
StarterWare在AM335X上的烧录运行 步骤:1.下载安装StarterWare,我们团购的SK需要02.00.00.07版本.最近外网访问慢,我上传到论坛.2.找一张miniSD卡,不需要 ...
- linux下ssd电子盘速度检测
代码: #include<stdio.h> #include<sys/time.h> #include <fcntl.h> #include <pthread ...
- Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'content' a
1.错误描述 org.hibernate.exception.DataException: could not execute statement at org.hibernate.exception ...
- WKWebView 加载本地HTML显示不出网页问题,这点你注意了吗?-------完美显示
1.首先,WKWebView的引入和创建,我这里就不做阐述,我要说的,就是解决别人不能给您解决的问题 2.WKWebView 加载本地HTML,也就是两三句代码 是吧?作为读者的您肯定也知道,也实现 ...
- lvs-dr 模式-piranha
系统: redhat 6.5 mini 机器名 ip vip lvs01(主lvs) 192.168.20.10 192.168.20.254 lvs02(备lvs) 192.168.20.20 rs ...
- 【洛谷T7153】(考试) 中位数
题目描述 给定 n 个数 a1, a2, ..., an,求这 n 个数两两的差值(共 n(n−1) 2 个)的中位数. 输入格式: 第一行一个正整数 n,表示数的个数. 接下来一行 n 个正整数,分 ...
- 【Chrome控制台】获取元素上绑定的事件信息以及监控事件
需求场景 在前端开发中,偶尔需要验证下某个元素上到底绑定了哪些事件,以及监控某个元素上的事件触发情况. 解决方案 普通操作 之前面对这种情况,一般采取的措施就是在各个事件里写console.info, ...
- win10怎么安装JDK8,配置JDK8的环境变量
win10怎么安装JDK8,配置JDK8的环境变量 本文详细说明怎么在win10上安装JDK8,方便小伙伴们快速学会安装与配置JDK. 工具/原料 windows10 jdk-8u51-windows ...
- 25.django Model
django ORM基本配置 django中遵循 Code Frist 的原则,即:根据代码中定义的类来自动生成数据库表 1.修改project数据库配置 (1)settigs.py里面 默认 DAT ...
- windows下编译caffe报错:error MSB4062: 未能从程序集 E:\NugetPackages\OpenCV.2.4.10\......的解决办法
参考博客:http://blog.csdn.net/u013277656/article/details/75040459 在windows上编译caffe时,用vs打开后会自动加载还原NugetPa ...