Java访问redis
添加依赖
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.MavenRedis
RedisProject
1.0-SNAPSHOT
war
RedisProject Maven Webapp
http://www.example.com
UTF-8
1.7
1.7
junit
junit
4.12
test
redis.clients
jedis
2.9.0
RedisProject
maven-clean-plugin
3.1.0
maven-resources-plugin
3.0.2
maven-compiler-plugin
3.8.0
maven-surefire-plugin
2.22.1
maven-war-plugin
3.2.2
maven-install-plugin
2.5.2
maven-deploy-plugin
2.8.2
Java连接redis
1 Jedis jedis = newJedis(ip, port);2 jedis.auth("123456");//权限认证
3 jedis.ping();4 jedis.select(0);//切换数据