SpringBoot redis 보초병 모드 사용
5895 단어 자바SpringBootredis
4.0.0
szw
springboot_redis_sentinel
0.0.1-SNAPSHOT
springboot_redis_sentinel
springboot redis
UTF-8
UTF-8
1.8
com.sicdt.sicsign.web.SicSignWebApplication
org.springframework.boot
spring-boot-starter-parent
1.4.2.RELEASE
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-aop
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-starter-redis
releases
Releases
http://192.168.3.71:8081/nexus/content/repositories/releases/
snapshots
Snapshots
http://192.168.3.71:8081/nexus/content/repositories/snapshots/
sicdt
Sicdt
http://192.168.3.71:8081/nexus/content/groups/public
spring-releases
https://repo.spring.io/libs-release
spring-releases
https://repo.spring.io/libs-release
org.apache.maven.plugins
maven-source-plugin
true
compile
jar
org.springframework.boot
spring-boot-maven-plugin
true
2. application. properties 설정
##
spring.redis.host=39.107.119.256
##
spring.redis.port=6381
## ( )
spring.redis.pool.max-active=300
## Redis ( 0)
spring.redis.database=0
## ( )
spring.redis.pool.max-wait=-1
##
spring.redis.pool.max-idle=100
##
spring.redis.pool.min-idle=20
## ( )
spring.redis.timeout=60000
#
spring.redis.sentinel.master=mymaster
spring.redis.sentinel.nodes=39.107.119.256:26379
3. 시작 클래스
package com.szw.redis;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SzwRedisApplication {
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(SzwRedisApplication.class, args);
}
}
4. 유닛 테스트 클래스
package com.sze.redis;
import javax.annotation.PostConstruct;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SentinelTest {
@Autowired
StringRedisTemplate redisTemplate;
ValueOperations stringRedis;
@PostConstruct
public void init(){
stringRedis=redisTemplate.opsForValue();
}
@Test
public void testString (){
stringRedis.set("name", "zz");
System.out.println(stringRedis.get("name"));
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.