记一次springboot配置redis项目启动时的一个奇怪的错误

目录
  • springboot配置redis项目启动时的错误
    • 总是爆出下面的错误
  • 解决springboot项目启动时redis报错
    • 出现ERRClientsentAUTH,butnopasswordisset的问题

springboot配置redis项目启动时的错误

在刚开始学redis时,我照着网上的教程,把redis和jedis整合到spring boot,整合完毕后,启动项目总是失败

总是爆出下面的错误

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.RepositoryConfigurationSource

***************************
APPLICATION FAILED TO START
***************************
 
Description:
 
An attempt was made to call the method org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/lang/String; but it does not exist. Its class, org.springframework.data.repository.config.RepositoryConfigurationSource, is available from the following locations:
 
jar:file:/D:/m2/repository/org/springframework/data/spring-data-commons/2.0.10.RELEASE/spring-data-commons-2.0.10.RELEASE.jar!/org/springframework/data/repository/config/RepositoryConfigurationSource.class
 
It was loaded from the following location:
 
file:/D:/m2/repository/org/springframework/data/spring-data-commons/2.0.10.RELEASE/spring-data-commons-2.0.10.RELEASE.jar
 
Action:
 
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.RepositoryConfigurationSource
 
2018-11-22 13:03:51.398 INFO 2196 --- [ main] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@1a451d4d: startup date [Thu Nov 22 13:03:50 CST 2018]; root of context hierarchy
 
Process finished with exit code 1

然后我在网上找了很久,都没有关于这个错误的解决办法,偶然看到一篇博客,它在启动项目时也出现了类型错误,也是jar包冲突,然后那个博主是通过改redis和jedis的版本号解决的,我也把版本号都改成和那个博主相同的,但启动后还是出现相同的错误。

后来就想如果我把版本号都去掉,让“spring-boot-starter-parent”自动为我们提供对应版本的jar包,这样就可以避免自己指定版本号时,可能会有一些意想不到的冲突。于是我就把redis和jedis的版本号都去掉,果然项目就可以正常启动了~~

What a strange error..

解决springboot项目启动时redis报错

出现ERR Client sent AUTH, but no password is set的问题

首先看下我springboot配置redis的部分如图:

显然上面配置了redis的启动密码为123456,

本地redis版本为3.0.1 在redis.windows.conf文件中requirepass内容也修改了密码为123456,这里说下,在去除requirepass前面的#号时一定注意还有一个空格要去除,不然会报错:

Invalid argument during startup: unknown conf file parameter :  requirepass

这时,说明redis密码与springboot的一致,接下来就是启动redis再启动springboot。

我员来的启动方式就是进入到redis的安装目录,执行redis-server.exe,然后正常启动。但是在启动springboot后,调用redis时就报错了,如图:

一开始以为是我Pom.xml文件中引入的为2.9.0的redis依赖导致的版本不兼容,一直去找Redis的2.9.0的安装包竟然网上没有。浪费了半天时间。

后来才发现,这个报错是告诉我没有设置密码。原因就是启动时的方法错误。

请务必记住,启动本地redis,如果设置了密码记得带上配置文件,启动命令完整为:

redis-server.exe redis.windows.conf

以上为个人经验,希望能给大家一个参考,也希望大家多多支持我们。

(0)

相关推荐

  • 在SpringBoot中添加Redis及配置方法

    在实际的开发中,会有这样的场景.有一个微服务需要提供一个查询的服务,但是需要查询的数据库表的数据量十分庞大,查询所需要的时间很长. 此时就可以考虑在项目中加入缓存. 引入依赖 在maven项目中引入如下依赖.并且需要在本地安装redis. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifac

  • springboot整合spring-data-redis遇到的坑

    描述 使用springboot整合redis,使用默认的序列化配置,然后使用redis-client去查询时查询不到相应的key. 使用工具发现,key的前面多了\xAC\xED\x00\x05t\x00!这样一个串. 而且value也是不能直观可见的. 问题所在 使用springdataredis,默认情况下是使用org.springframework.data.redis.serializer.JdkSerializationRedisSerializer这个类来做序列化. org.spri

  • 在SpringBoot中注入RedisTemplate实例异常的解决方案

    目录 注入RedisTemplate实例异常 贴出详细的错误日志 最后想再验证一个小的问题 注入RedisTemplate实例异常 最近,在项目开发过程中使用了RedisTemplate,进行单元测试时提示 Field redisTemplate in com.example.demo1.dao.RedisDao required a bean of type ‘org.springframework.data.redis.core.RedisTemplate’ that could not b

  • 记一次springboot配置redis项目启动时的一个奇怪的错误

    目录 springboot配置redis项目启动时的错误 总是爆出下面的错误 解决springboot项目启动时redis报错 出现ERRClientsentAUTH,butnopasswordisset的问题 springboot配置redis项目启动时的错误 在刚开始学redis时,我照着网上的教程,把redis和jedis整合到spring boot,整合完毕后,启动项目总是失败 总是爆出下面的错误 Correct the classpath of your application so

  • SpringBoot项目启动时如何读取配置以及初始化资源

    介绍   在开发过程中,我们有时候会遇到非接口调用而出发程序执行任务的一些场景,比如我们使用quartz定时框架通过配置文件来启动定时任务时,或者一些初始化资源场景等触发的任务执行场景. 方法一:注解 方案   通过使用注解@Configuration和@Bean来初始化资源,配置文件当然还是通过@Value进行注入. @Configuration:用于定义配置类,可替换xml配置文件,被注解的类内部一般是包含了一个或者多个@Bean注解的方法. @Bean:产生一个Bean对象,然后将Bean

  • springboot使用CommandLineRunner解决项目启动时初始化资源的操作

    前言: 在我们实际工作中,总会遇到这样需求,在项目启动的时候需要做一些初始化的操作,比如初始化线程池,提前加载好加密证书等. 今天就给大家介绍一个 Spring Boot 神器,专门帮助大家解决项目启动初始化资源操作. 这个神器就是 CommandLineRunner,CommandLineRunner 接口的 Component 会在所有 Spring Beans 都初始化之后,SpringApplication.run() 之前执行,非常适合在应用程序启动之初进行一些数据初始化的工作. 正文

  • SpringBoot配置Redis实现保存获取和删除数据

    目录 1 Redis 2 Maven依赖 3 application.propertis 4 RedisConfig 5 RedisService 6 调试代码 7 调试结果 1 Redis Redis 是完全开源的,遵守 BSD 协议,是一个高性能的 key-value 数据库. Redis 与其他 key - value 缓存产品有以下三个特点: (1)Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用. (2)Redis不仅仅支持简单的key-val

  • SpringBoot配置Redis自定义过期时间操作

    SpringBoot配置Redis自定义过期时间 Redis配置依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-redis</artifactId> <version>1.4.4.RELEASE</version> </dependency> <dependency>

  • springboot中项目启动时实现初始化方法加载参数

    目录 springboot项目启动,初始化方法加载参数 1.@PostConstruct说明 2.@PreDestroy说明 第一种:注解@PostConstruct 第二种:实现CommandLineRunner接口 第三种:springboot的启动类 springboot初始化参数顺序 spring初始化参数顺序为 springboot项目启动,初始化方法加载参数 今天我看到项目中用到了 @PostConstruct 这个注解,之前没看到过,特地查了一下, 1.@PostConstruct

  • SpringBoot项目启动时增加自定义Banner的简单方法

    目录 前言 制作Banner 总结 前言 最近有小伙伴推荐给博客启动的时候加上自定义Banner,开始我还不太明白他说的是那部分,后面给我发了这样一个文件,陌溪瞬间就懂了 ////////////////////////////////////////////////////////////////////   //                          _ooOoo_                               //   //                    

  • springboot配置ssl后启动一直是端口被占用的解决

    目录 springboot配置ssl后启动一直是端口被占用 springboot端口被占用一招解决 解决步骤 springboot配置ssl后启动一直是端口被占用 srpingboot 配置 SSL 一直说密码不对然后端口被占用 我之前是这么写的 然后运行报错 怎么解决的呢 就是 把文件放到了 根目录 然后这样写 就解决了 // An highlighted blo #端口号 server.port=8089 #SSL配置 server.ssl.key-store=2503725_xcx.goo

  • SpringBoot集成SwaggerUi以及启动时遇到的错误

    SwaggerUi是一个自动生成接口文档,并且还可以去测试这些接口的东西. SpringBoot集成SwaggerUi 引入依赖 <properties> <swagger.version>2.6.1</swagger.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> &l

  • java如何实现项目启动时执行指定方法

    本文实例为大家分享了java项目启动时执行指定方法,供大家参考,具体内容如下 想到的就是监听步骤如下: 1.配置web.xml <listener> <listener-class>com.listener.InitListener</listener-class> </listener> 2.编写InitListener类 package com.listener; import java.io.File; import javax.servlet.Ser

随机推荐