Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Redis连接失败_Spring_Maven_Spring Boot_Redis - Fatal编程技术网

Spring Redis连接失败

Spring Redis连接失败,spring,maven,spring-boot,redis,Spring,Maven,Spring Boot,Redis,我想用Redis来操纵会话。但是我在运行spring boot应用程序时失败了。所以我猜这个错误是来自maven依赖关系,特别是版本冲突 以下是我的maven依赖项: <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa<

我想用Redis来操纵会话。但是我在运行spring boot应用程序时失败了。所以我猜这个错误是来自maven依赖关系,特别是版本冲突

以下是我的maven依赖项:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.session</groupId>
        <artifactId>spring-session-data-redis</artifactId>
        <version>1.7.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>io.lettuce</groupId>
        <artifactId>lettuce-core</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
</dependencies>
<dependencies>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-test</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.session</groupId>
    <artifactId>spring-session-data-redis</artifactId>
</dependency>
它是从以下位置加载的:

文件:/C:/Users/aoutir/.m2/repository/org/springframework/data/spring-data-redis/2.0.10.RELEASE/spring-data-redis-2.0.10.RELEASE.jar

行动:

更正应用程序的类路径,使其包含org.springframework.data.redis.connection.RedisConnection的单个兼容版本


非常感谢您的帮助,提前感谢您的回复。

只需删除spring会话数据redis的显式版本,并使用spring boot父pom的版本。

如果要更改spring会话数据redis的版本,必须确保父pom不管理任何可传递依赖项。如果我降级到版本1.3(找不到版本1.7),我最终会出现以下版本不匹配,如
mvn-X dependency:tree

[ESC[1;36mDEBUGESC[m]    org.springframework.session:spring-session-data-redis:jar:1.3.3.RELEASE:compile
[ESC[1;36mDEBUGESC[m]       org.apache.commons:commons-pool2:jar:2.5.0:compile (version managed from 2.4.2)
[ESC[1;36mDEBUGESC[m]       org.springframework.data:spring-data-redis:jar:2.0.10.RELEASE:compile (version managed from 1.7.10.RELEASE)

请替换依赖项

 <dependency>
    <groupId>org.springframework.session</groupId>
    <artifactId>spring-session-data-redis</artifactId>
    <version>1.7.0.RELEASE</version>
 </dependency>

org.springframework.session
spring会话数据redis
1.7.0.1发布


org.springframework.boot
弹簧启动机redis

版本管理是自动完成的,启动的将初始化redis缓存。

我花了一整天的时间来解决完全相同的问题。经过一整天的研发,我找到了解决方案

dependencies {
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
implementation('org.springframework.boot:spring-boot-starter-data-rest')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-security')
implementation('org.springframework.boot:spring-boot-starter-data-redis')
implementation('org.springframework.session:spring-session-data-redis')

runtimeOnly('org.springframework.boot:spring-boot-devtools')
testImplementation('org.springframework.boot:spring-boot-starter-test')
runtimeOnly('org.flywaydb:flyway-core')
runtimeOnly('com.h2database:h2')


// runtimeOnly('mysql:mysql-connector-java')
}

使用“spring启动程序数据redis”和“spring会话数据redis”。 删除lettuse依赖项,因为它作为依赖项包含在spring boot starter数据redis中

以下是您的依赖项:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.session</groupId>
        <artifactId>spring-session-data-redis</artifactId>
        <version>1.7.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>io.lettuce</groupId>
        <artifactId>lettuce-core</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
</dependencies>
<dependencies>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-test</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.session</groupId>
    <artifactId>spring-session-data-redis</artifactId>
</dependency>

org.springframework.boot
spring引导启动器数据jpa
org.springframework.boot
弹簧启动安全
org.springframework.boot
SpringBootStarterWeb
mysql
mysql连接器java
运行时
org.springframework.boot
弹簧起动试验
测试
org.springframework.security
弹簧安全性试验
测试
org.springframework.boot
spring启动程序数据redis
org.springframework.session
spring会话数据redis

我遇到了完全相同的问题。即使在我的pom中,我也有以下内容:org.springframework.session spring session 1.3.5.RELEASE org.springframework.boot spring boot starter data redis org.springframework.session spring session data redis。我知道发生了什么事吗?我遇到了完全相同的问题。尽管在我的pom中,我有以下内容:org.springframework.session spring session 1.3.5.RELEASE org.springframework.boot spring boot starter data redis org.springframework.session spring session data redis any idea,发生了什么?您是否删除了lettuse依赖项,因为它作为依赖项包含在spring boot starter数据redis中。?