From springBoot1.x to springBoot2.x, there are many changes. Among them, springBoot2.x supports spring5 and webflux, which are relatively new things. However, during the process of project upgrade, I found that many configurations and methods are not the same Next summarize
1.springboot replacement version
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.4.2.RELEASE</version><relativePath/><!--lookupparentfromrepository--></parent>复制代码
replace
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.1.RELEASE</version></parent>复制代码
2. Redis version replacement
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-redis</artifactId></dependency>复制代码
Replace with
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>复制代码
3. Data source modification removes unnecessary introduction of DataSourceBuilder
importorg.springframework.beans.factory.annotation.Qualifier;importorg.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;importorg.springframework.boot.context.properties.ConfigurationProperties;importorg.springframework.boot.jdbc.DataSourceBuilder;importorg.springframework.boot.web.servlet.FilterRegistrationBean;importorg.springframework.boot.web.servlet.ServletRegistrationBean;importorg.springframework.context.annotation.Bean;importorg.springframework.context.annotation.Configuration;importorg.springframework.context.annotation.Primary;importorg.springframework.jdbc.datasource.DataSourceTransactionManager;importorg.springframework.stereotype.Component;importorg.springframework.transaction.PlatformTransactionManager;复制代码
4.nacos version replacement
<dependency><groupId>com.alibaba.boot</groupId><artifactId>nacos-config-spring-boot-starter</artifactId><version>0.1.6</version></dependency>复制代码
Replace with
<dependency><groupId>com.alibaba.boot</groupId><artifactId>nacos-config-spring-boot-starter</artifactId><version>0.2.1</version></dependency>复制代码
5. Tomcat version replacement
<tomcat.version>8.5.11</tomcat.version>复制代码
Replace with
<tomcat.version>8.5.24</tomcat.version>复制代码
6. Connection pool version changes
<!--alibaba数据库连接池druid配置--><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.0.28</version></dependency>复制代码
replace
<dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.12</version></dependency>复制代码
java code change
Change to
7. Some configuration files have expired, delete them directly
server.context-path=spring.redis.pool.max-active=100spring.redis.pool.max-idle=8spring.redis.pool.max-wait=-1spring.redis.pool.min-idle=1复制代码
8. Replace the mysql driver
The original driver has expired.
com.mysql.jdbc.Driver 复制代码
To
com.mysql.cj.jdbc.Driver复制代码
9. Verification
Successful start!