1. 程式人生 > >springboot連線redis單機版

springboot連線redis單機版

1 首先redis要開啟

cd redis-3.0.0 cd /usr/local/redis19 cd bin/ ./redis-server redis.conf ps -aux | grep redis 看到埠號出來就證明啟動了

2 pom.xml中 加入

<!-- 加入redis起步依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>

application.properties 

加入  spring.redis.host=ip地址
spring.redis.port=6379  埠號

3  main檔案 加入  @EnableCaching       


4 controller方法上加上   @Cacheable(value="findAllUsers")