redis How to Connect to Redis in Java using Jedis Getting Jedis


Example

The Jedis library is generally added to Java project using a dependency management system built into the build environment of the project. Two popular Java build systems are Maven and Gradle.

Using Gradle

To add the Jedis library to a Gradle project, you will need configure a repository and add a dependency. The following snippet shows how to add version 2.9.0 of the Jedis library to a Gradle project.

repositories {
    mavenCentral()
}

dependencies {
    compile 'redis.clients:jedis:2.9.0'
}

Using Maven

To add Jedis to a Maven project, you need to add a dependency to your dependency list and provide the coordinates of the library. The following snippet would be added to your pom.xml file:

<dependencies>
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>2.9.0</version>
    </dependency>
</dependencies>