@SpringBootApplication
@Slf4j
public class RedisTestApp {
public static void main(String[] args) throws InterruptedException {
ApplicationContext ctx = SpringApplication.run(RedisTestApp.class, args);
StringRedisTemplate template = ctx.getBean(StringRedisTemplate.class);
template.opsForValue().set("hello","world");
String retval = template.opsForValue().get("hello");
log.info("set hello to "+retval);
System.exit(0);
}
}
spring:
redis:
host: xxx.xxx.xxx.xxx
port: 6379
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>