SpringBoot를 처음 사용하여 Redis에 연결하면 많은 구성 파일이있어 학습 시작시 경험이 없습니다. 실제로 SpringBoot를 사용하여 Redis에 연결할 때는 많은 구성이 필요하지 않습니다.
먼저 Redis 서버를 활성화합니다 .
그런 다음 SpringBoot에서 구성 파일을 추가하십시오.
# redis database index (기본값은 0) spring.redis.database = 0# redis server address spring.redis.redis.redis.redis.redis.Redis Connection Port spring.redis.port = 6379# redis 서버 연결 암호 (기본값이 비어 있음) spring.Redis.Password =# 연결 풀에 최대의 연결 수단을 사용하지 않음). 연결 풀의 경우 (음수 값 사용) spring.redis.pool.max-wait = -1# 연결 풀 스프링 스프링 스프링 스프링.
마지막으로 SpringBoot의 pom.xml 파일에 종속성을 추가하십시오.
<pectionency> <groupId> org.springframework.boot </groupid> <artifactid> 스프링 부트 스타터-데이터-레 디스 </artifactid> </fectionency>
그런 다음 SpringBoot 프로젝트에서 테스트 클래스를 작성하십시오.
@runwith (springrunner.class) @springboottestpublic class shoppout ArrayList <> (); list.add ( "a"); list.add ( "b"); list.add ( "v"); StringRedistemplate.opsforValue (). set ( "abc", "sted"); stringRedistemplate.opsForList (). LeftPushall ( "QQ", List); // 저장 ListStringRedistemPlate.OpSforList (). 범위 ( "QWE", 0, -1) .foreach (value-> {System.out.println (value);});}그런 다음 새로 만든 Redis에서 하나를 볼 수 있습니다.
그런 다음 SpringBoot에서 Redis에 연결하는 가장 쉬운 방법입니다.
요약
위의 내용은 SpringBoot의 Redis와의 예비 연결에 대한 자세한 설명입니다. 모든 사람에게 도움이되기를 바랍니다. 관심있는 친구들은이 사이트를 계속 참조 할 수 있습니다.
SpringBoot 최적화 팁
스프링 부트 마이크로 서비스 프로젝트에 권장되는 배포 방법
Springboot의 봄에 장점
단점이 있으면 메시지를 남겨 두십시오. 이 사이트를 지원해 주신 친구들에게 감사드립니다!