首先,加入springboot升级大版本依赖,会在升级过程中打印出错日志提示(升级完毕可去除)
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-properties-migrator</artifactId><version>2.6.3</version>
</dependency>
涉及更新版本对比
报错提价的部分依赖
<dependency><groupId>org.hibernate</groupId><artifactId>hibernate-validator</artifactId><version>5.2.4.Final</version>
</dependency>
<dependency><groupId>com.lmax</groupId><artifactId>disruptor</artifactId><version>3.4.2</version>
</dependency>
log4j2配置文件也要修改,不然会默认使用springboot配置或不生效
<?xml version="1.0" encoding="UTF-8"?>
<!-- 默认异步输出日志,修改为同步时需要将RollingRandomAccessFile元素修改为RollingFile,将asyncLogger修改为Logger,将asyncRoot修改为Root --><configuration status="OFF"><appenders><Console name="Console" target="SYSTEM_OUT"><!-- <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY" />--><PatternLayout pattern="[%d{HH:mm:ss.SSS}] %-5level %class{36} %L %M - %msg%xEx%n" /></Console><RollingRandomAccessFile name="RollingFileDebug" immediateFlush="false" fileName="./logs/debug.log" filePattern="logs/$${date:yyyy-MM}/debug-%d{yyyy-MM-dd}-%i.log.gz"><Filters><ThresholdFilter level="DEBUG" /><ThresholdFilter level="INFO" onMatch="DENY" onMismatch="NEUTRAL" /></Filters><PatternLayout pattern="%d %m%n"/><Policies><TimeBasedTriggeringPolicy interval="1" modulate="true"/></Policies><DefaultRolloverStrategy max="30" /></RollingRandomAccessFile><RollingRandomAccessFile name="RollingFileInfo" immediateFlush="false" fileName="./logs/info.log" filePattern="logs/$${date:yyyy-MM}/info-%d{yyyy-MM-dd}-%i.log.gz"><Filters><ThresholdFilter level="INFO" /><ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL" /></Filters><PatternLayout pattern="[%d{yyyy-MM-dd HH:mm:ss}] %-5level %class{36} %L %M - %msg%xEx%n" /><Policies><TimeBasedTriggeringPolicy interval="1" modulate="true"/></Policies><DefaultRolloverStrategy max="30" /></RollingRandomAccessFile><RollingRandomAccessFile name="RollingFileWarn" immediateFlush="false" fileName="./logs/warn.log" filePattern="logs/$${date:yyyy-MM}/warn-%d{yyyy-MM-dd}-%i.log.gz"><Filters><ThresholdFilter level="WARN" /><ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="NEUTRAL" /></Filters><PatternLayout pattern="[%d{yyyy-MM-dd HH:mm:ss}] %-5level %class{36} %L %M - %msg%xEx%n" /><Policies><TimeBasedTriggeringPolicy interval="1" modulate="true"/></Policies><DefaultRolloverStrategy max="30" /></RollingRandomAccessFile><RollingRandomAccessFile name="RollingFileError" immediateFlush="false" fileName="./logs/error.log" filePattern="logs/$${date:yyyy-MM}/error-%d{yyyy-MM-dd}-%i.log.gz"><ThresholdFilter level="ERROR" /><PatternLayout pattern="[%d{yyyy-MM-dd HH:mm:ss}] %-5level %class{36} %L %M - %msg%xEx%n" /><Policies><TimeBasedTriggeringPolicy interval="1" modulate="true"/></Policies><DefaultRolloverStrategy max="30" /></RollingRandomAccessFile></appenders><loggers><asyncLogger name="org.eclipse" level="WARN" includeLocation="true"/><asyncLogger name="org.springframework" level="WARN" includeLocation="true"/><asyncLogger name="org.hibernate" level="WARN" includeLocation="true"/><!--<asyncLogger name="org.hibernate.type.descriptor.sql.BasicBinder" level="trace"/>--><asyncLogger name="log4jdbc.log4j2" level="error" additivity="false"><appender-ref ref="Console"/></asyncLogger><!--设置为OFF,即屏蔽; 留下sqltiming作为INFO级别输出--><asyncLogger name="jdbc.connection" level="OFF"/><asyncLogger name="jdbc.resultset" level="OFF"/><asyncLogger name="jdbc.resultsettable" level="OFF"/><asyncLogger name="jdbc.audit" level="OFF"/><asyncLogger name="jdbc.sqltiming" level="OFF"/><asyncLogger name="jdbc.sqlonly" level="OFF"/><asyncRoot level="info" includeLocation="true"><appender-ref ref="Console" /><appender-ref ref="RollingFileInfo" /><appender-ref ref="RollingFileWarn" /><appender-ref ref="RollingFileError" /><appender-ref ref="RollingFileDebug" /></asyncRoot></loggers>
</configuration>
application.yml参数名也要修改,可以根据idea提示进行修改,如
库类名变化
shiro不进入鉴权过滤器,但能进入realm问题
升级心得:大部分报错是因为依赖冲突导致,可以先在网上找到兼容的版本相对应进行升级,或者找到能够正常运行的项目或demo进行对比,之后排除依赖冲突
依赖冲突解决办法:
首先依赖冲突就是一个项目中,使用了不同版本的依赖,那么解决办法就是找到这两个版本的依赖然后排除掉其中一个
方法1:确定项目使用本身使用哪个依赖,exclude不需要的版本
方法2:如果方法1排除不掉的话,直接在pom文件中加入依赖冲突的依赖坐标以及项目所需要的依赖版本号