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 ...
随机推荐
- WebService之CXF注解之三(Service接口实现类)
ITeacherServiceImpl.java: /** * @Title:ITeacherServiceImpl.java * @Package:com.you.service.impl * @D ...
- Educational Codeforces Round37 E - Connected Components?
#include <algorithm> #include <cstdio> #include <iostream> #include <queue> ...
- 在.Net Core中使用MongoDB的入门教程(二)
在上一篇文章中,讲到了MongoDB在导入驱动.MongoDB的连接,数据的插入等. 在.Net Core中使用MongoDB的入门教程(一) 本篇文章将接着上篇文章进行介绍MongoDB在.Net ...
- 手机端仿ios的单级联动脚本三
脚本 <script>var weekdayArr=['非公司企业法人','个体工商户','私营独资企业','私营合伙企业','有限责任公司','股份有限责任公司'];var mobile ...
- 浅谈js中null和undefined的区别
在JS中,null和undefined是经常让人摸不着头脑的东西,尤其是在数据初始化以及处理的过程中,经常稍微不注意,就会让页面在渲染时出现报错,下面来细说下,这两者之间的区别: null 表示一个对 ...
- javascript学习记录-2-18
对象定义的几种方法: var person=new Object(); person.name="111"; person.age=22; 或 var person={ na ...
- [BZOJ1008] [HNOI2008] 越狱 (数学)
Description 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种.如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱 In ...
- equals与==号的区别?
equals与 == 的区别 初学Java的人(me),有很长一段时间对equals()这个方法感到很懊恼,实在是弄不明白到底何时比较的是地址,又什么时候比较内容呢?因为要找工作,要面试.本人通过查阅 ...
- 详解MySQL数据类型
原文地址http://www.cnblogs.com/xrq730/p/5260294.html,转载请注明出处,谢谢! 前言 很久没写文章,也有博友在我的有些文章中留言,希望我可以写一些文章,公司项 ...
- Cannot find a valid baseurl for repo: base
Linux下执行yum命令的时候一直报错:Cannot find a valid baseurl for repo: base 网上找了好多办法都没有解决... 我之前也遇到过一次, vi /etc/ ...