介绍
这篇文章给大家介绍弹簧引导中mybatis的二级缓存怎么使用复述,集群进行替换,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
1。砰的一声。xml添加相关依赖
& lt; parent> & lt; groupId> org.springframework.boot & lt; artifactId> spring-boot-starter-parent & lt; version> 1.5.1.RELEASE & lt;/parent> & lt; !——依赖——比; & lt; dependencies> & lt; !——mybatis祝辞 & lt; dependency> & lt; groupId> org.mybatis.spring.boot & lt; artifactId> mybatis-spring-boot-starter & lt; version> 1.2.0 & lt;/dependency> & lt; !——复述,相关——比; & lt; dependency> & lt; groupId> redis.clients & lt; artifactId> jedis & lt;/dependency> & lt; dependency> & lt; groupId> org.springframework.data & lt; artifactId> spring-data-redis & lt;/dependency> & lt; dependencies>
2。配置复述,集群,参考spring-data-redis官方文档
@ component @ConfigurationProperties(前缀=皊pring.redis.cluster") 公开课ClusterConfigurationProperties {/* * spring.redis.cluster。节点[0]=127.0.0.1:7379 * spring.redis.cluster。[1]=127.0.0.1:7380节点 *…… */List节点;/* * *得到初始已知集群节点的集合{@code主机:端口}格式。 * * @return */公共List getNodes () { 返回节点; } 公共空间setNodes (List 节点){ 这一点。节点=节点; } } @ configuration 公开课AppConfig {/* * * application.properties的类型安全表示 */@ autowired ClusterConfigurationProperties clusterProperties; @ bean RedisConnectionFactory公共connectionFactory () { 返回新JedisConnectionFactory ( 新RedisClusterConfiguration (clusterProperties.getNodes ())); } }
3。自定义二级缓存类
弹簧引导中mybatis的二级缓存怎么使用复述,集群进行替换