导入这个jar包

    1. <dependency>
    2. <groupId>com.github.yuyenews</groupId>
    3. <artifactId>mars-extends-all</artifactId>
    4. <version>最新版,具体看版本指引</version>
    5. </dependency>

    在mars.yml文件里添加如下配置

    1. #redis配置
    2. redis:
    3. # 这些都有默认值,可以不配
    4. maxTotal: 10
    5. maxIdle: 20
    6. minIdle: 2
    7. numTestsPerEvictionRun: 10000
    8. timeBetweenEvictionRunsMillis: 10000
    9. minEvictableIdleTimeMillis: 10000
    10. softMinEvictableIdleTimeMillis: 10000
    11. maxWaitMillis: 1000
    12. testOnBorrow: true
    13. testWhileIdle: true
    14. testOnReturn: true
    15. jmxEnabled: false
    16. jmxNamePrefix: pool
    17. blockWhenExhausted: false
    18. # 这个必须配置
    19. jedisShardInfos:
    20. -
    21. name: master
    22. host: 10.211.55.5
    23. port: 6379
    24. password: 123456

    用RedisTemplete进行redis操作

    1. RedisTemplete.set(key,value);
    2. RedisTemplete.get(key,value);
    3. Jedis里的其他方法都支持

    generated by haroopad