微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何简单地激活redis

如何解决如何简单地激活redis

我认为对于spring boot中的mvc项目的设计,可以稍后添加,简单的redis到项目中。

我已经尝试了几天将 redis 添加到我的项目中,但遇到了困难。

我在我的 pom 中添加了这个:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

我在 main 中添加了这个

@Cacheable

我有这个错误信息:

Spring Data Redis - Could not safely identify store assignment for repository candidate interface *. If you want this repository to be a Redis repository,consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred),or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.keyvalueRepository.

然后按照我添加的关于stackoverflow的解释:

#spring.data.redis.repositories.type=none
#spring.data.ldap.repositories.enabled=false
spring.main.allow-bean-deFinition-overriding=true

但我收到了这条消息:

Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost/<unresolved>:6379

是的,它无法连接,但我认为通过添加@Cacheable,一切都会自动配置?!

我显然迷路了,我以为就这么简单!

你有一个好的链接,以便我可以在我的项目上设置 redis?谢谢

非常感谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。