当前位置: 首页 > 知识库问答 >
问题:

redis混合Spring靴

吕皓
2023-03-14

我想把春靴和Redis混在一起。以下是依赖项:https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent/1.5.10.release https://mvnrepository.com/artifact/org.springframework.data/spring-data-redis/2.0.4.release

然而,当我实现redis bean时,我得到一个错误:

java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional;

有没有可能这两个依赖关系不混在一起?

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;

@Configuration
public class RedisConfiguration {
    @Value("${redis.host}")
    private String host;
    @Value("${redis.port}")
    private int port;
    @Value("${redis.pw}")
    private String password;
    @Value("${redis.user}")
    private String user;

    @Bean
    JedisConnectionFactory jedisConnectionFactory() {
        System.out.println("setting up port: " + this.port);
        JedisConnectionFactory jedisConFactory
                = new JedisConnectionFactory();
        jedisConFactory.setHostName(this.host);
        jedisConFactory.setClientName(this.user);
        jedisConFactory.setPort(this.port);
        jedisConFactory.setPassword(this.password);
        return jedisConFactory;
    }

    @Bean
    public RedisTemplate<String, Object> redisTemplate() {
        RedisTemplate<String, Object> template = new RedisTemplate<>();
        template.setConnectionFactory(jedisConnectionFactory());
        return template;
    }

}

pom.xml

 <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.10.RELEASE</version>
  </parent>

  <dependencies>
 <dependency>
      <groupId>org.springframework.data</groupId>
      <artifactId>spring-data-redis</artifactId>
      <version>2.0.4.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>redis.clients</groupId>
      <artifactId>jedis</artifactId>
      <version>2.9.0</version>
      <type>jar</type>
    </dependency>
  </dependencies>

dep树:

[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.5.10.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:1.5.10.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.10.RELEASE:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.1.11:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.1.11:compile
[INFO] |  |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] |  |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.17:compile
[INFO] |  \- org.springframework.boot:spring-boot-actuator:jar:1.5.10.RELEASE:compile
[INFO] |     \- org.springframework:spring-context:jar:4.3.14.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.5.10.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.10.RELEASE:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.27:compile
[INFO] |  |  |  \- org.apache.tomcat:tomcat-annotations-api:jar:8.5.27:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.27:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.27:compile
[INFO] |  +- org.hibernate:hibernate-validator:jar:5.3.6.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
[INFO] |  |  \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile
[INFO] |  +- org.springframework:spring-web:jar:4.3.14.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-beans:jar:4.3.14.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:4.3.14.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:4.3.14.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-jersey:jar:1.5.10.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-validation:jar:1.5.10.RELEASE:compile
[INFO] |  +- org.glassfish.jersey.core:jersey-server:jar:2.25.1:compile
[INFO] |  |  +- org.glassfish.jersey.core:jersey-common:jar:2.25.1:compile
[INFO] |  |  |  +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.25.1:compile
[INFO] |  |  |  \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] |  |  +- org.glassfish.jersey.core:jersey-client:jar:2.25.1:compile
[INFO] |  |  +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] |  |  +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.25.1:compile
[INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] |  |  +- org.glassfish.hk2:hk2-api:jar:2.5.0-b32:compile
[INFO] |  |  |  +- org.glassfish.hk2:hk2-utils:jar:2.5.0-b32:compile
[INFO] |  |  |  \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.5.0-b32:compile
[INFO] |  |  +- org.glassfish.hk2.external:javax.inject:jar:2.5.0-b32:compile
[INFO] |  |  \- org.glassfish.hk2:hk2-locator:jar:2.5.0-b32:compile
[INFO] |  +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.25.1:compile
[INFO] |  +- org.glassfish.jersey.containers:jersey-container-servlet:jar:2.25.1:compile
[INFO] |  +- org.glassfish.jersey.ext:jersey-bean-validation:jar:2.25.1:compile
[INFO] |  +- org.glassfish.jersey.ext:jersey-spring3:jar:2.25.1:compile
[INFO] |  |  +- org.glassfish.hk2:hk2:jar:2.5.0-b32:compile
[INFO] |  |  |  +- org.glassfish.hk2:config-types:jar:2.5.0-b32:compile
[INFO] |  |  |  +- org.glassfish.hk2:hk2-core:jar:2.5.0-b32:compile
[INFO] |  |  |  +- org.glassfish.hk2:hk2-config:jar:2.5.0-b32:compile
[INFO] |  |  |  +- org.glassfish.hk2:hk2-runlevel:jar:2.5.0-b32:compile
[INFO] |  |  |  \- org.glassfish.hk2:class-model:jar:2.5.0-b32:compile
[INFO] |  |  |     \- org.glassfish.hk2.external:asm-all-repackaged:jar:2.5.0-b32:compile
[INFO] |  |  \- org.glassfish.hk2:spring-bridge:jar:2.5.0-b32:compile
[INFO] |  \- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.25.1:compile
[INFO] |     +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.25.1:compile
[INFO] |     +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.8.10:compile
[INFO] |     \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.8.10:compile
[INFO] |        \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.8.10:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.10.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:1.5.10.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.10.RELEASE:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] |  |  \- net.minidev:json-smart:jar:2.2.1:test
[INFO] |  |     \- net.minidev:accessors-smart:jar:1.1:test
[INFO] |  |        \- org.ow2.asm:asm:jar:5.0.3:test
[INFO] |  +- junit:junit:jar:4.12:test
[INFO] |  +- org.assertj:assertj-core:jar:2.6.0:test
[INFO] |  +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.1:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.4.0:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  +- org.springframework:spring-core:jar:4.3.14.RELEASE:compile
[INFO] |  \- org.springframework:spring-test:jar:4.3.14.RELEASE:test
[INFO] +- com.zaxxer:HikariCP:jar:2.5.1:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.webjars:webjars-locator:jar:0.32-1:compile
[INFO] |  \- org.webjars:webjars-locator-core:jar:0.32:compile
[INFO] |     \- org.apache.commons:commons-compress:jar:1.9:compile
[INFO] +- org.webjars:bootstrap:jar:4.0.0:compile
[INFO] |  +- org.webjars:jquery:jar:3.0.0:compile
[INFO] |  \- org.webjars.npm:popper.js:jar:1.11.1:compile
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:1.5.10.RELEASE:runtime
[INFO] |  +- org.springframework.boot:spring-boot:jar:1.5.10.RELEASE:compile
[INFO] |  \- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.10.RELEASE:compile
[INFO] +- io.swagger:swagger-jersey2-jaxrs:jar:1.5.13:compile
[INFO] |  \- org.glassfish.jersey.media:jersey-media-multipart:jar:2.25.1:compile
[INFO] |     \- org.jvnet.mimepull:mimepull:jar:1.9.6:compile
[INFO] +- io.swagger:swagger-jaxrs:jar:1.5.13:compile
[INFO] |  +- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] |  +- org.reflections:reflections:jar:0.9.10:compile
[INFO] |  |  +- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] |  |  \- com.google.code.findbugs:annotations:jar:2.0.1:compile
[INFO] |  \- com.google.guava:guava:jar:20.0:compile
[INFO] +- io.swagger:swagger-models:jar:1.5.13:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] +- io.swagger:swagger-core:jar:1.5.13:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.2.1:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.8.10:compile
[INFO] |  \- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] +- io.swagger:swagger-annotations:jar:1.5.13:compile
[INFO] +- org.projectlombok:lombok:jar:1.16.16:provided
[INFO] +- org.springframework.data:spring-data-redis:jar:2.0.4.RELEASE:compile
[INFO] |  +- org.springframework.data:spring-data-keyvalue:jar:1.2.10.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:1.13.10.RELEASE:compile
[INFO] |  |  \- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
[INFO] |  +- org.springframework:spring-tx:jar:4.3.14.RELEASE:compile
[INFO] |  +- org.springframework:spring-oxm:jar:4.3.14.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.3.14.RELEASE:compile
[INFO] |  \- org.springframework:spring-context-support:jar:4.3.14.RELEASE:compile
[INFO] \- redis.clients:jedis:jar:2.9.0:compile
[INFO]    \- org.apache.commons:commons-pool2:jar:2.4.3:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

共有1个答案

陶胤运
2023-03-14

Spring Boot 1.x和Spring Data 2.x不兼容。要么完全停留在1.x线上,要么升级到Spring Boot2.0,预定今天发布。

 类似资料:
  • 在redis 4.0中,讨论了一个新的混合RDB AOF,在redis更改日志中输入链接描述: 混合RDB-AOF格式。如果启用,则在重写AOF文件时使用新格式:重写使用更紧凑、更快的格式生成RDB格式,并将AOF流附加到文件中。这允许在使用AOF持久性时更快地重写和重新加载 我想知道如何在redis配置文件中设置此配置?

  • OpenGL中,混合(Blending)通常是实现物体透明度(Transparency)的一种技术。透明就是说一个物体(或者其中的一部分)不是纯色(Solid Color)的,它的颜色是物体本身的颜色和它背后其它物体的颜色的不同强度结合。一个有色玻璃窗是一个透明的物体,玻璃有它自己的颜色,但它最终的颜色还包含了玻璃之后所有物体的颜色。这也是混合这一名字的出处,我们混合(Blend)(不同物体的)多

  • 有一个只接受内容类型multipart/mixed的REST API。 正在尝试使用restTemplate并生成内容类型为multipart/mixed的REST请求。如果注释setContentType restTemplate默认为多部分/表单数据。 但运气不好,举个例子,我如何调用API生成多部分/混合请求? 也许这个有帮助

  • 本文向大家介绍详解java之redis篇(spring-data-redis整合),包括了详解java之redis篇(spring-data-redis整合)的使用技巧和注意事项,需要的朋友参考一下 1,利用spring-data-redis整合 项目使用的pom.xml: 除了log部分,只有一个spring core 和 spring-data-redis了 项目文件目录结构: applica

  • 我希望将后端公开为“资源”(如Restlet),并消除服务层,以便Rest资源可以直接与Dao交互。这样,资源就是契约,而不是接口。 如果事务由Spring本地管理,在Spring MVC 3控制器上使用@Transactional语义学是否有问题?回滚和捕捉异常有什么问题吗?

  • 混合(Mixins)提供一种方法来组合和重用常用组件属性集。它们使用<a-mixin>元素来定义并被放置在 <a-assets>中。Mixins必须有一个id,并且当一个实体把id设置为其mixin属性时,该实体将吸收这个mixin的所有属性。 <a-scene> <a-assets> <a-mixin material="color: red"></a-mixin> <a-mixi