【问题标题】:NoSuchMethodError exception with spring-data-redisspring-data-redis 的 NoSuchMethodError 异常
【发布时间】:2018-04-06 04:51:27
【问题描述】:

在将发布序列升级到 Kay-RELEASE 的 spring 数据后开始出现以下异常。

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$1(<generated>)
at org.egov.infra.config.redis.RedisServerConfiguration$$EnhancerBySpringCGLIB$$f89e20ba$$FastClassBySpringCGLIB$$1ac62136.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,也不存在不同版本的 jars。我正在使用弹簧 4.3.12.RELEASE

【问题讨论】:

    标签: spring spring-data spring-data-redis


    【解决方案1】:

    我今天也遇到了同样的问题,并求助于 Gitter 寻求帮助。他们说:

    Spring Data 2.x 不适用于 Spring Boot 1.x 请升级到 Spring Boot 2.0 M5 或暂时留在 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>
    

    【讨论】:

    • 感谢@Wilfred 的建议。我没有使用 spring-boot 并且将 spring-data-elasticsearch 升级到最新是我们使用最新的 elasticsearch 客户端的要求
    • 在这种情况下,也许您可​​以通过以下方式获得更多信息:gitter.im/spring-projects/spring-data 他们可能会提供帮助。
    【解决方案2】:

    spring-data Kay-RELEASE (aka 2.0.0) 不适用于 Spring v4.3.X <. springframework v>.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-26
      • 2021-09-13
      • 2021-08-19
      • 2015-09-26
      • 2019-05-03
      • 2015-02-08
      • 1970-01-01
      相关资源
      最近更新 更多