1. Add dependent configuration file in the pom.xml
<-! Redis dependent -> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <-! Jedis dependent -> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency>
2. Writing Test Methods
@Test void redisTest () { // connected Redis database, acquires connection object Jedis jedis = new new Jedis ( "localhost" ); // write data to the database Redis jedis.set ( "name", "John Doe" ); / / read data database Redis String name = jedis.get ( "name" ); // printout System.out.println (name); }
3. Success