从springBoot1.x到springBoot2.x,有很多内容变化,其中springBoot2.x支持spring5以及webflux,这是一些比较新的东西,但是我在项目升级的过程中,发现很多配置以及方法与原来不一样,接下来总结下
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.4.2.RELEASE</version><relativePath/><!--lookupparentfromrepository--></parent>复制代码
更换
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.1.RELEASE</version></parent>复制代码
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-redis</artifactId></dependency>复制代码
更换为
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>复制代码
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;复制代码
<dependency><groupId>com.alibaba.boot</groupId><artifactId>nacos-config-spring-boot-starter</artifactId><version>0.1.6</version></dependency>复制代码
更换为
<dependency><groupId>com.alibaba.boot</groupId><artifactId>nacos-config-spring-boot-starter</artifactId><version>0.2.1</version></dependency>复制代码
<tomcat.version>8.5.11</tomcat.version>复制代码
更换为
<tomcat.version>8.5.24</tomcat.version>复制代码
<!--alibaba数据库连接池druid配置--><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.0.28</version></dependency>复制代码
更换
<dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.12</version></dependency>复制代码
java代码变更
变更为
7.配置文件一些配置过期了,直接删掉
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.更换mysql驱动
原来的驱动已经过期了 ,将
com.mysql.jdbc.Driver 复制代码
改为
com.mysql.cj.jdbc.Driver复制代码
9.验证
启动成功!