zoukankan      html  css  js  c++  java
  • java连接redis

      (1)首先引入jar包

          <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>1.6</version>
          </dependency>
          <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.9.0</version>
          </dependency>

      (2)由于我的redis是安装在虚拟机上的linux,所以必须关闭防火墙(或者指定开放端口),不然java程序连接服务器的返回连接被拒绝。

          Redhat使用了SELinux来增强安全,关闭的办法为:

          1. 永久有效
          修改 /etc/selinux/config 文件中的 SELINUX="" 为 disabled ,然后重启。
          2. 即时生效
          setenforce 0
          关闭防火墙的方法为:
          1. 永久性生效
          开启:chkconfig iptables on 
          关闭:chkconfig iptables off
          2. 即时生效,重启后失效
          开启:service iptables start
          关闭:service iptables stop 
      (3)java代码如下:
          
  • 相关阅读:
    我的python菜鸟之路11
    我的SAS菜鸟之路9
    我的python菜鸟之路10
    idea中tomcat9打印日志乱码
    2、dockerfile命令
    1、Docker 打包本地镜像
    1、Centos7下MongoDB下载安装详细步骤
    4、自定义service 服务
    3、杀死某个服务下的多个进程
    3、python导出依赖环境时报错
  • 原文地址:https://www.cnblogs.com/gdpuzxs/p/6624101.html
Copyright © 2011-2022 走看看