提交 17bd70be 编写于 作者: 武汉红喜's avatar 武汉红喜

redis

上级 0f7f3031
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
<commons-dbcp.version>1.4</commons-dbcp.version> <commons-dbcp.version>1.4</commons-dbcp.version>
<mysql-connector-java.version>5.1.32</mysql-connector-java.version> <mysql-connector-java.version>5.1.32</mysql-connector-java.version>
<spring.data.redis.verion>1.8.6.RELEASE</spring.data.redis.verion>
<commons-lang.version>2.6</commons-lang.version> <commons-lang.version>2.6</commons-lang.version>
<commons-collections.version>3.2.2</commons-collections.version> <commons-collections.version>3.2.2</commons-collections.version>
<commons-codec.version>1.11</commons-codec.version> <commons-codec.version>1.11</commons-codec.version>
...@@ -429,6 +431,12 @@ ...@@ -429,6 +431,12 @@
<version>${jedis.version}</version> <version>${jedis.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${spring.data.redis.verion}</version>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
......
...@@ -31,17 +31,13 @@ ...@@ -31,17 +31,13 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>redis.clients</groupId>
<artifactId>spring-boot-starter</artifactId> <artifactId>jedis</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>spring-data-redis</artifactId>
</dependency> <optional>true</optional>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
...@@ -55,42 +51,16 @@ ...@@ -55,42 +51,16 @@
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
</dependency> </dependency>
</dependencies>
<build> <dependency>
<finalName>${project.artifactId}</finalName> <groupId>junit</groupId>
<resources> <artifactId>junit</artifactId>
<resource> </dependency>
<directory>src/main/resources</directory> <dependency>
<filtering>true</filtering> <groupId>org.springframework</groupId>
</resource> <artifactId>spring-test</artifactId>
</resources> </dependency>
<plugins> </dependencies>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>${springloaded.version}</version>
</dependency>
</dependencies>
<!-- POM不是继承spring-boot-starter-parent的话,需要下面的指定 -->
<configuration>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>
\ No newline at end of file
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
<module>whatsmars-boot-sample-cache</module> <module>whatsmars-boot-sample-cache</module>
<module>whatsmars-boot-sample-mongodb</module> <module>whatsmars-boot-sample-mongodb</module>
<module>whatsmars-boot-sample-elasticsearch</module> <module>whatsmars-boot-sample-elasticsearch</module>
<module>whatsmars-boot-sample-redis</module>
</modules> </modules>
<dependencies> <dependencies>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>whatsmars-spring-boot-samples</artifactId>
<groupId>org.hongxi</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>whatsmars-boot-sample-redis</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.6.0</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package org.hongxi.whatsmars.redis.client; package org.hongxi.whatsmars.boot.sample.redis;
import org.hongxi.whatsmars.redis.client.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.StringRedisTemplate;
/** /**
* Created by javahongxi on 2017/12/5. * Created by javahongxi on 2017/12/5.
*/ */
@SpringBootApplication @SpringBootApplication
public class App implements CommandLineRunner { public class SampleRedisApplication implements CommandLineRunner {
@Autowired @Autowired
private RedisService redisService; private StringRedisTemplate stringRedisTemplate;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(App.class, args); SpringApplication.run(SampleRedisApplication.class, args);
} }
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
redisService.set("count", "1"); stringRedisTemplate.opsForValue().set("count", "1");
System.out.println(redisService.get("count")); System.out.println(stringRedisTemplate.opsForValue().get("count"));
} }
} }
...@@ -2,12 +2,13 @@ spring: ...@@ -2,12 +2,13 @@ spring:
redis: redis:
host: 127.0.0.1 host: 127.0.0.1
port: 6379 port: 6379
timeout: 0 timeout: 10000
pool: lettuce:
max-active: 8 pool:
max-idle: 8 max-active: 8
max-wait: -1 max-idle: 8
min-idle: 0 max-wait: -1
min-idle: 0
# cluster: # cluster:
# max-redirects: 5 # max-redirects: 5
# nodes: 127.0.0.1:6380,127.0.0.1:6381 # nodes: 127.0.0.1:6380,127.0.0.1:6381
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册