提交 89a72d96 编写于 作者: 武汉红喜's avatar 武汉红喜

whatsmars-redis demo

上级 d4d82ee1
......@@ -98,6 +98,16 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.hongxi</groupId>
<artifactId>whatsmars-redis</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
......
......@@ -4,6 +4,7 @@ import org.hongxi.whatsmars.spring.boot.config.UserConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
......@@ -15,6 +16,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableConfigurationProperties({UserConfig.class})
@ImportResource(locations={"classpath*:spring/*.xml"})
@ComponentScan({"org.hongxi.whatsmars.spring.boot", "org.hongxi.whatsmars.redis.client"})
public class App {
public static void main(String[] args) {
......
package org.hongxi.whatsmars.spring.boot.controller;
import org.hongxi.whatsmars.redis.client.service.RedisStringService;
import org.hongxi.whatsmars.spring.boot.async.MessageService;
import org.hongxi.whatsmars.spring.boot.dao.UserMapper;
import org.slf4j.Logger;
......@@ -22,6 +23,8 @@ public class InitRunner implements CommandLineRunner {
private UserMapper userMapper;
@Autowired
private MessageService messageService;
@Autowired
private RedisStringService redisStringService;
@Override
public void run(String... args) throws Exception {
......@@ -31,5 +34,9 @@ public class InitRunner implements CommandLineRunner {
for (int i = 0; i < 10; i++) {
messageService.send("message" + i);
}
String key = "domain";
redisStringService.set(key, "hongxi.org", 60); // 60s
System.out.println(redisStringService.get(key));
}
}
......@@ -56,6 +56,15 @@ spring:
test-while-idle: true
time-between-eviction-runs-millis: 5000
validation-query: SELECT 1
redis:
host: 127.0.0.1
port: 6379
timeout: 10000
pool:
max-active: 8
max-idle: 8
max-wait: -1
min-idle: 0
server:
port: 8081
tomcat:
......@@ -87,6 +96,15 @@ spring:
test-while-idle: true
time-between-eviction-runs-millis: 5000
validation-query: SELECT 1
redis:
host: 127.0.0.1
port: 6379
timeout: 10000
pool:
max-active: 8
max-idle: 8
max-wait: -1
min-idle: 0
server:
port: 8081
tomcat:
......@@ -118,6 +136,15 @@ spring:
test-while-idle: true
time-between-eviction-runs-millis: 5000
validation-query: SELECT 1
redis:
host: 127.0.0.1
port: 6379
timeout: 10000
pool:
max-active: 8
max-idle: 8
max-wait: -1
min-idle: 0
server:
port: 8081
tomcat:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册