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 ...
随机推荐
- 使用jsoup抓取新闻信息
1,jsoup简介 jsoup 是一款Java 的HTML解析器,可直接解析某个URL地址.HTML文本内容.它提供了一套非常省力的API,可通过DOM,CSS以及类似于jQuery的操作方法来取出和 ...
- No bean named 'hibernateTemplate' is defined
1.错误描述 WARN:2015-05-01 15:42:22[localhost-startStop-1] - Exception encountered during context initia ...
- java中的“\t”
对于初学者来说,java中的"\t"和空格总是让人迷惑,其实很简单,通过一个例子就能很快明白! 比如说打印九九乘法表! 先来看用空格的效果! package cn.edu.nwpu ...
- 玲珑杯#2.5 A-B
这个题解错了网上还没有题解 囧 = (i%2)? 1 : -1 = - * * *= m #include<bits/stdc++.h> using namespace std; type ...
- Ball HDU - 4811
Jenny likes balls. He has some balls and he wants to arrange them in a row on the table. Each of tho ...
- java实现马踏棋盘问题
1.问题描述: 在国际象棋中,马走日,用户输入棋盘的起始位置从x:0-4,y:0-3输出从这一点开始,马走完整个棋盘的各个方案,并输出方案数 2.输入样式: 请输入棋盘马起始位置: 0 0 3.输出样 ...
- 求字符串空格、数字、字母个数--JAVA基础
相关内容:charAt()函数 package com.nxl123.www;public class NumString { public static void main(String[] arg ...
- Mybatis入门看这一篇就够了
什么是MyBatis MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为 ...
- haproxy的stick table复制
在上一篇文章中,分析了haproxy的stick table特性和用法,其中特性之一也是很实用的特性是stick table支持在haproxy多个节点之间进行复制(replication). 本文仅 ...
- python 想搞加密算法吗?快戳这里
加密算法介绍 一,HASH Hash,一般翻译做"散列",也有直接音译为"哈希"的,就是把任意长度的输入(又叫做预映射,pre-image),通过散列算法,变换 ...