Configure Spring Data Redis

Source: Internet
Author: User
Tags download redis

Prepare beforehand

1. Download Redis

https://github.com/MicrosoftArchive/redis/releases/tag/win-3.2.100

2. Download the Redis visualization tool

Https://redisdesktop.com/download

3. Start Redis

CD%redis%

Redis-server.exe

Configuration

4, Pom.xml additional

Spring-data-redis

Jedis

5. New Redis/redis.properties

redis.hostname=localhostredis.port=6379#redis.password=

6. New Springframework/spring-redis.xml

<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:context= "Http://www.springframework.org/schema/context"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://www.springframework.org/schema/beans Http://www.springframework.org/schema/beans/spring-beans. XSD Http://www.springframework.org/schema/context http://www.springframework.org/schema/cont Ext/spring-context.xsd ">    <Context:property-placeholder Location= "Classpath:redis/redis.properties"ignore-unresolvable= "true" />    <BeanID= "Redisconnectionfactory"class= "Org.springframework.data.redis.connection.jedis.JedisConnectionFactory">        < Propertyname= "HostName"value= "${redis.hostname}" />        < Propertyname= "Port"value= "${redis.port}" />    </Bean>    <BeanID= "Redistemplate"class= "Org.springframework.data.redis.core.RedisTemplate">        < Propertyname= "ConnectionFactory"ref= "Redisconnectionfactory" />    </Bean>    <BeanID= "CacheManager"class= "Org.springframework.data.redis.cache.RedisCacheManager">        <Constructor-argref= "Redistemplate" />        < Propertyname= "Defaultexpiration"value= " the" />    </Bean></Beans>

8, ensure that spring-redis.xml can be introduced into the Application-context.xml

<resource= "Classpath:springframework/spring-*.xml"/>

7. At this point, the cache can be implemented by appending @cacheable @CachePut @CacheEvict to the method of the Serviceimpl class.

Configure Spring Data Redis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.