配置问题 spring boot 和 redis
Problem in configuring spring boot and redis
我有一个旧的 spring 启动应用程序 (1.5.0-FINAL),我无法更改此版本。
我想将 redis 添加到我的应用程序中,这就是我所做的:
1) 添加了 maven dep:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>1.5.10.RELEASE</version>
</dependency>
2) 将 属性 添加到我的引导
@EnableCaching
public class MySpringBootApp{
3) 添加配置属性以检查它是否启动连接:
spring.cache.type: redis
spring.redis.host: 192.168.99.100
spring.redis.port: 6379
上面的 host/port 不存在:我只想在启动时看到类似 "connection error" 的内容,以确保我配置了所有内容但没有出现!似乎 spring 引导只是不尝试使用缓存。
我是不是遗漏了什么?也许我的 spring 引导版本太旧了?
Spring Boot parent pom 已经定义了 starters 的版本,因此从 spring-boot-starter-data-redis 依赖项中删除该版本。
您的 pom.xml 至少有这些依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
接下来,@EnableCaching 将查找带有@Cacheable 或@CachePut 注释的bean。
我有一个旧的 spring 启动应用程序 (1.5.0-FINAL),我无法更改此版本。 我想将 redis 添加到我的应用程序中,这就是我所做的:
1) 添加了 maven dep:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>1.5.10.RELEASE</version>
</dependency>
2) 将 属性 添加到我的引导
@EnableCaching
public class MySpringBootApp{
3) 添加配置属性以检查它是否启动连接:
spring.cache.type: redis
spring.redis.host: 192.168.99.100
spring.redis.port: 6379
上面的 host/port 不存在:我只想在启动时看到类似 "connection error" 的内容,以确保我配置了所有内容但没有出现!似乎 spring 引导只是不尝试使用缓存。
我是不是遗漏了什么?也许我的 spring 引导版本太旧了?
Spring Boot parent pom 已经定义了 starters 的版本,因此从 spring-boot-starter-data-redis 依赖项中删除该版本。
您的 pom.xml 至少有这些依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
接下来,@EnableCaching 将查找带有@Cacheable 或@CachePut 注释的bean。