報錯:An attempt was made to call a method that does not exist. The attempt was made from the following location:
阿新 • • 發佈:2021-12-13
springboot整合redis時引入jar包報錯:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2021-12-13 15:56:24.872 ERROR 24864 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: An attempt was made to call a method that does not exist. The attempt was made from the following location: org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration$PoolBuilderFactory.getPoolConfig(LettuceConnectionConfiguration.java:188) The following method did not exist: org.apache.commons.pool2.impl.GenericObjectPoolConfig.setMaxWait(Ljava/time/Duration;)V The calling method's class, org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration$PoolBuilderFactory, was loaded from the following location: jar:file:/D:/develop_toops/maven/maven_repository/org/springframework/boot/spring-boot-autoconfigure/2.6.1/spring-boot-autoconfigure-2.6.1.jar!/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration$PoolBuilderFactory.class The called method's class, org.apache.commons.pool2.impl.GenericObjectPoolConfig, is available from the following locations: jar:file:/D:/develop_toops/maven/maven_repository/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar!/org/apache/commons/pool2/impl/GenericObjectPoolConfig.class The called method's class hierarchy was loaded from the following locations: org.apache.commons.pool2.impl.GenericObjectPoolConfig: file:/D:/develop_toops/maven/maven_repository/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar org.apache.commons.pool2.impl.BaseObjectPoolConfig: file:/D:/develop_toops/maven/maven_repository/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar org.apache.commons.pool2.BaseObject: file:/D:/develop_toops/maven/maven_repository/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar Action: Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration$PoolBuilderFactory and org.apache.commons.pool2.impl.GenericObjectPoolConfig
解決辦法:
將依賴中版本號刪除,springboot會自動匹配合適的版本
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>