IDEA springboot集成ehcache单节点和redis集群
2018-03-18 19:21
786 查看
1. IDEA springboot集成ehcache和redis
1.1 集成redis(1) 新建springboot项目
Next
Next
Finish 等待加载工程所需依赖,如果加载无差错项目可以直接运行
(2) 添加redis所需要的包(在pom.xml)
到http://mvnrepository.com/搜索redis
选着spring data redis
<!--https://mvnrepository.com/artifact/org.springframework.data/spring-data-redis-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
(3) 编写配置文件(application.properties)server.port=80 (服务端口号)
spring.redis.database=0 (redis数据库选择,redis数据库默认情况下有十六个,可以通过配置文件增加数量,对于单机情况下才会有数据库的概念,集群环境下是没有数据库概念的,会随机存到所有的数据库下)
spring.redis.host=localhost (redis服务地址)
spring.redis.port=6379(redis端口号,可以在配置文件修改)
(4) 使用注解开启redis服务
(5) 编写redis配置类,把redistemplete注入容器
(6) 编写测试类
1.2 Springboot 集成redis集群
(1) Redis集群使用的是Jedis依赖,先引入jedis依赖
<!--jedis依赖-->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
(2) 编写Jedis配置文件
(3) 配置读取
(4) 别写配置类获取集群链接,将链接对象注入容器
(5) 编写测试类
1.3 Springboot 集成 ehcache
(1) 添加依赖包(2) <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
<version>1.4.2.RELEASE</version>
</dependency>(3) 编写配置文件application.propertise
在resource下添加ehcache.xml编写配置文件
(4) 使用注解编写缓存类主要使用@Caehcache
标注:部分有借鉴如有侵权请联系244774097@qq.com
1.1 集成redis(1) 新建springboot项目
Next
Next
Finish 等待加载工程所需依赖,如果加载无差错项目可以直接运行
(2) 添加redis所需要的包(在pom.xml)
到http://mvnrepository.com/搜索redis
选着spring data redis
<!--https://mvnrepository.com/artifact/org.springframework.data/spring-data-redis-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
(3) 编写配置文件(application.properties)server.port=80 (服务端口号)
spring.redis.database=0 (redis数据库选择,redis数据库默认情况下有十六个,可以通过配置文件增加数量,对于单机情况下才会有数据库的概念,集群环境下是没有数据库概念的,会随机存到所有的数据库下)
spring.redis.host=localhost (redis服务地址)
spring.redis.port=6379(redis端口号,可以在配置文件修改)
(4) 使用注解开启redis服务
(5) 编写redis配置类,把redistemplete注入容器
(6) 编写测试类
1.2 Springboot 集成redis集群
(1) Redis集群使用的是Jedis依赖,先引入jedis依赖
<!--jedis依赖-->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
(2) 编写Jedis配置文件
(3) 配置读取
(4) 别写配置类获取集群链接,将链接对象注入容器
(5) 编写测试类
1.3 Springboot 集成 ehcache
(1) 添加依赖包(2) <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
<version>1.4.2.RELEASE</version>
</dependency>(3) 编写配置文件application.propertise
在resource下添加ehcache.xml编写配置文件
(4) 使用注解编写缓存类主要使用@Caehcache
标注:部分有借鉴如有侵权请联系244774097@qq.com
相关文章推荐
- springboot集成redis集群(带密码并序列化)
- SpringBoot获取Redis集群实例有缺少的问题->为Redis集群新增节点分配slot
- Spring-Boot (四) cache/ehcache/redis-cache集成使用
- Springboot2.X集成redis集群(Lettuce)连接的方法
- SpringBoot集成redis集群存储字符串和对象
- IntelliJ IDEA Spring Boot(6) 集成Hibernate+Shiro+Ehcache
- IntelliJ IDEA Spring Boot(7) 集成Hibernate+Shiro+Ehcache(2)
- 37. Spring Boot集成EHCache实现缓存机制【从零开始学Spring Boot】
- spring boot 集成redis
- 35. Spring Boot集成Redis实现缓存机制【从零开始学Spring Boot】
- idea快速创建maven集成spring-boot项目
- spring boot 集成redis实现分布式session共享
- springboot + redis集群实现session共享
- 【转载】Springboot整合 一 集成 redis
- 关于Spring boot 与 redis 的集成,以及Spring中redis的使用
- spring boot 自学笔记(三) Redis集成—RedisTemplate
- Spring Data Redis 单节点和集群配置和RedisTemplate用法
- 浅谈SpringBoot集成Redis实现缓存处理(Spring AOP实现)
- Redis-3.0.6 集群部署集成SpringJava工程-----环境搭建
- 37. Spring Boot集成EHCache实现缓存机制【从零开始学Spring Boot】