spring-data-redis 的 NoSuchMethodError 异常
NoSuchMethodError exception with spring-data-redis
将发布列车升级到 spring 数据的 Kay-RELEASE 后,开始出现以下异常。
Caused by: java.lang.NoSuchMethodError: org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V
at org.springframework.data.redis.connection.RedisStandaloneConfiguration.<init>(RedisStandaloneConfiguration.java:61)
at org.egov.infra.config.redis.RedisServerConfiguration.redisConnectionFactory(RedisServerConfiguration.java:86)
at org.egov.infra.config.redis.RedisServerConfiguration$$EnhancerBySpringCGLIB$$f89e20ba.CGLIB$redisConnectionFactory(<generated>)
at org.egov.infra.config.redis.RedisServerConfiguration$$EnhancerBySpringCGLIB$$f89e20ba$$FastClassBySpringCGLIB$ac62136.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
已仔细检查所有 jars 依赖项,既不存在重复也不存在不同版本的 jars。我正在使用 spring 4.3.12.RELEASE
我 运行 今天也遇到了同样的问题,于是在 Gitter 上寻求帮助。他们说:
Spring Data 2.x does not work with Spring Boot 1.x
Please upgrade to Spring Boot 2.0 M5 or stay for the time being on Spring Data Redis 1.x
我认为切换到 Kay-RELEASE 会导致使用 2.0.0.RELEASE 其他数据库,从而导致错误。
所以我把spring-data-redis换成了1.8.7.RELEASE然后我不得不改
spring-data-commons 到 1.13.8.RELEASE 和 spring-data-keyvalue 到 1.2.8.RELEASE.
我的 POM 文件现在是:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>elasticache</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>elasticache</name>
<description>Elasticache test</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath/>
</parent>
<repositories>
<repository>
<id>spring-repo</id>
<name>Spring Repository</name>
<url>https://repo.spring.io/release</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.12</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.13.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-keyvalue</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.8.7.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-elasticache</artifactId>
<version>1.11.218</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Kay-RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.4.1.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.8.RELEASE</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
</plugins>
</build>
spring-data Kay-RELEASE(又名 2.0.0)不适用于 Spring v4.3.X <。
它仅适用于 springframework v 5.0.0 >.
将发布列车升级到 spring 数据的 Kay-RELEASE 后,开始出现以下异常。
Caused by: java.lang.NoSuchMethodError: org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V
at org.springframework.data.redis.connection.RedisStandaloneConfiguration.<init>(RedisStandaloneConfiguration.java:61)
at org.egov.infra.config.redis.RedisServerConfiguration.redisConnectionFactory(RedisServerConfiguration.java:86)
at org.egov.infra.config.redis.RedisServerConfiguration$$EnhancerBySpringCGLIB$$f89e20ba.CGLIB$redisConnectionFactory(<generated>)
at org.egov.infra.config.redis.RedisServerConfiguration$$EnhancerBySpringCGLIB$$f89e20ba$$FastClassBySpringCGLIB$ac62136.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
已仔细检查所有 jars 依赖项,既不存在重复也不存在不同版本的 jars。我正在使用 spring 4.3.12.RELEASE
我 运行 今天也遇到了同样的问题,于是在 Gitter 上寻求帮助。他们说:
Spring Data 2.x does not work with Spring Boot 1.x Please upgrade to Spring Boot 2.0 M5 or stay for the time being on Spring Data Redis 1.x
我认为切换到 Kay-RELEASE 会导致使用 2.0.0.RELEASE 其他数据库,从而导致错误。
所以我把spring-data-redis换成了1.8.7.RELEASE然后我不得不改 spring-data-commons 到 1.13.8.RELEASE 和 spring-data-keyvalue 到 1.2.8.RELEASE.
我的 POM 文件现在是:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>elasticache</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>elasticache</name>
<description>Elasticache test</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath/>
</parent>
<repositories>
<repository>
<id>spring-repo</id>
<name>Spring Repository</name>
<url>https://repo.spring.io/release</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.12</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.13.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-keyvalue</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.8.7.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-elasticache</artifactId>
<version>1.11.218</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Kay-RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.4.1.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.8.RELEASE</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
</plugins>
</build>
spring-data Kay-RELEASE(又名 2.0.0)不适用于 Spring v4.3.X <。 它仅适用于 springframework v 5.0.0 >.