The configuration of spring boot1 to spring boot2 varies greatly, and the following changes are found during the migration project to spring Boot2
The Redis configuration for 1.java adds a property Jedis
Old version
Spring
Redis
timeout:300000
Pool.max-active:20
Pool.max-idle:5
Pool.max-wait:-1
pool.min-idle:0
New
Spring
Redis
timeout:300000
Jedis:
Pool.max-active:20
Pool.max-idle:5
Pool.max-wait:-1
pool.min-idle:0
2.tomcat the original thread pool @bean configuration is no longer supported, but the YAML or properties configuration has not changed
YAML configuration:
Server
Tomcat:
Uri-encoding:utf-8
max-threads:1000
max-connections:900
min-spare-threads:100
@bean Configuration for version 1:
@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. Project Access path configuration, version 2 new Servlet properties added
Old version:
Server
port:8089
Context-path:/brieftkheal
Servlet-path:/
New:
Server
port:8089
Servlet:
Context-path:/brieftkheal
Path:/
4. The entity class configuration parameter prefix in the new version does not let the hump-type name, but uses '-' split open, for example:
Old version:
@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
New:
@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. Interceptors Handlerinterceptor blocked static resources by default in version 2.0.0 Resource
Handlermethod, skip the static resources.
Handlermethod object interception, if using Swagger interface API, need to add judgment
if (o instanceof handlermethod)
6.spirngboot2.0 version fully supports the partial method return type of JAVA8,JPA from the original T into the
Optional<t>, such as Findbyid,findone, for example, to get the entity class T, use the Optional.get () method
The configuration of the 7.RedisCacheManager class has changed, I have not found the configuration method at present, hope to advise
Well, now find these, welcome to add and point out the inadequacy
The changes that spring boot 1.x.x to spring boot 2.x.x