1 jar包冲突
- 下载Maven Helper插件
- 检查冲突
2 包依赖
druid包依赖mybatis包。使用druid时必须同时添加mybatis。
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
3 SpringCloud与OpenFeign冲突
SpringCloud与OpenFeign版本不兼容,出现错误:
Could not find class [org.springframework.cloud.client.loadbalancer.reactive.OnNoRibbonDefaultCondition]
- 方案
SpringCloud与OpenFeign配置兼容版本
SpringCloud版本
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
OpenFeign版本
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
- 查询OpenFeign版本
https://mvnrepository.com/
4 excludePathPatterns不生效
原因:访问某个接口(路由)时,发生错误,重定向到/error路径,因此需要排除拦截/error路径。
方案:
InterceptorRegistration registration = registry.addInterceptor(new TokenInterceptor());
registration.addPathPatterns("/**");
registration.excludePathPatterns("/**/error");
5 lettuce与sleuth版本冲突
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.cloud.sleuth.instrument.redis.TraceLettuceClientResourcesBeanPostProcessor.postProcessAfterInitialization(TraceRedisAutoConfiguration.java:100)
The following method did not exist:
io.lettuce.core.tracing.BraveTracing.builder()Lio/lettuce/core/tracing/BraveTracing$Builder;
The method’s class, io.lettuce.core.tracing.BraveTracing, is available from the following locations:
jar:file:/D:/installsoftware/install/maven/apache-maven-3.6.1/localrepository/io/lettuce/lettuce-core/5.1.8.RELEASE/lettuce-core-5.1.8.RELEASE.jar!/io/lettuce/core/tracing/BraveTracing.class
原因:jar包冲突,同一个功能,jar包版本不一致
现场:SpringBoot2.1.7.RELEASE,Sleuth2.2.5.RELEASE
解决:修改Sleuth版本为:2.1.7.RELEASE
6 分页拦截器冲突
- 异常
Caused by: org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: java.lang.RuntimeException: 在系统中发现了多个分页插件,请检查系统配置!
Cause: java.lang.RuntimeException: 在系统中发现了多个分页插件,请检查系统配置! - 原因
SpringBoot版本为2.4.5,在resources/mybatis-config.xml配置中添加了分页拦截器配置:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
<setting name="logImpl" value="STDOUT_LOGGING" />
</settings>
<!-- 引入 pageHelper插件 -->
<!--注意这里要写成PageInterceptor, 5.0之前的版本都是写PageHelper, 5.0之后要换成PageInterceptor-->
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!--reasonable:分页合理化参数,默认值为false,直接根据参数进行查询。
当该参数设置为 true 时,pageNum<=0 时会查询第一页, pageNum>pages(超过总数时),会查询最后一页。-->
<property name="reasonable" value="true"/>
</plugin>
</plugins>
</configuration>
- 方案
将pageHelper拦截删除或注释。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
<setting name="logImpl" value="STDOUT_LOGGING" />
</settings>
</configuration>
7 java: 程序包org.springframework.data.redis.core不存在
- 问题
IDEA启动时,无法加载Redis依赖。 - 方案
命令行启动服务:
mvn spring-boot:run -D maven.test.skip=true