Application of Redis in Spring Boot project (i.)

Source: Internet
Author: User
Tags redis redis server

Https://github.com/xetorthio/jedis explains how to add Jedis dependencies to spring boot.

Add the following code under Pom.xml

<dependency>
    <groupId>redis.clients</groupId>
    <artifactid>jedis</artifactid >
    <version>2.8.0</version>
    <type>jar</type>
    <scope>compile</ Scope>
</dependency>


Adding in the main function

    	Jedis Jedis = new Jedis ("localhost");
    	Scanner in=new Scanner (system.in);
    	while (true) {
    		String name = In.next ();
			String value = jedis.get (name);
			System.out.println (value);
    	}


First install the Redis server and run the Redis Service (Installation method: http://blog.csdn.net/firenet1/article/details/50786562)

Then enable the client to enter a set of data

127.0.0.1:6379> set foo bar
ok
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379>



Then after compiling, input foo in the console will get output bar, at this time the test project can be normal Unicom Redis

Foo
bar
nulx
null


Spring Boot website uses Redis's tutorial address for http://spring.io/guides/gs/messaging-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.