当前位置: 首页 > news >正文

银行网站建设方案app拉新项目推广代理

银行网站建设方案,app拉新项目推广代理,重庆seo薪酬水平,安徽东莞建设集团有限公司SpringBoot系列之集成Jedis教程#xff0c;Jedis是老牌的redis客户端框架#xff0c;提供了比较齐全的redis使用命令#xff0c;是一款开源的Java 客户端框架#xff0c;本文使用Jedis3.1.0加上Springboot2.0#xff0c;配合spring-boot-starter-data-redis使用#xff0…SpringBoot系列之集成Jedis教程Jedis是老牌的redis客户端框架提供了比较齐全的redis使用命令是一款开源的Java 客户端框架本文使用Jedis3.1.0加上Springboot2.0配合spring-boot-starter-data-redis使用只给出简单的使用demo 软件环境 JDK 1.8 SpringBoot 2.2.1 Maven 3.2 Mysql 8.0.26 spring-boot-starter-data-redis 2.2.1 jedis3.1.0 开发工具 IntelliJ IDEA smartGit 项目搭建 使用Spring官网的https://start.spring.io快速创建Spring Initializr项目 选择maven、jdk版本 选择需要的Dependencies选择一下Spring Data Redis 点击next就可以生成一个Springboot项目不过jedis客户端配置还是要自己加的所以对pom文件做简单的修改spring-boot-starter-data-redis默认使用lettuce所以不用的可以exclusion然后再加上jedis的配置 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-redis/artifactIdexclusionsexclusiongroupIdio.lettuce/groupIdartifactIdlettuce-core/artifactId/exclusion/exclusions /dependencydependencygroupIdredis.clients/groupIdartifactIdjedis/artifactId /dependency新建一个application.yml配置文件加上redis一些配置 spring:redis:port: 6379host: 127.0.0.1password:timeout: 3000database: 1jedis:pool:max-idle: 8max-active: 8min-idle: 2 新增Redis配置配置RedisConnectionFactory 为JedisConnectionFactoryJedisPoolRedisTemplate需要用到也可以配置一下 package com.example.jedis.configuration;import lombok.extern.slf4j.Slf4j; import org.apache.commons.pool2.impl.GenericObjectPool; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.jedis.JedisConnection; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig;Configuration ConditionalOnClass({GenericObjectPool.class, JedisConnection.class, Jedis.class}) EnableRedisRepositories(basePackages com.example.jedis.repository) Slf4j public class RedisConfiguration {Beanpublic JedisPoolConfig jedisPoolConfig() {return new JedisPoolConfig();}Beanpublic JedisPool jedisPool() {return new JedisPool(jedisPoolConfig());}Beanpublic RedisConnectionFactory jedisConnectionFactory() {return new JedisConnectionFactory();}Beanpublic RedisTemplateString, Object redisTemplate() {RedisTemplateString, Object template new RedisTemplateString, Object();template.setConnectionFactory(jedisConnectionFactory());template.setKeySerializer(new StringRedisSerializer());template.setValueSerializer(new GenericJackson2JsonRedisSerializer());return template;} }写一个实体类RedisHash定义存储的hash key package com.example.jedis.model;import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; import org.springframework.data.redis.core.RedisHash;import java.io.Serializable;RedisHash(user) Data SuperBuilder(toBuilder true) EqualsAndHashCode AllArgsConstructor NoArgsConstructor public class UserDto implements Serializable {private static final long serialVersionUID 5962011647926411830L;public enum Gender {MALE, FEMALE}private Long id;private String name;private Gender gender;} 使用Sping Data Redis的API来实现一个CRUD接口 package com.example.jedis.repository;import com.example.jedis.model.UserDto; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository;Repository public interface UserRepository extends CrudRepositoryUserDto, Long { } 写一个测试类来进行测试ContextConfiguration指定一个配置类 package com.example.jedis;import cn.hutool.core.util.IdUtil; import com.example.jedis.configuration.RedisConfiguration; import com.example.jedis.model.UserDto; import com.example.jedis.repository.UserRepository; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool;SpringBootTest ContextConfiguration(classes RedisConfiguration.class) DirtiesContext(classMode DirtiesContext.ClassMode.BEFORE_CLASS) class SpringbootJedisApplicationTests {AutowiredJedisPool jedisPool;AutowiredRedisTemplate redisTemplate;AutowiredUserRepository userRepository;Testvoid contextLoads() {Jedis jedis jedisPool.getResource();jedis.set(tKey,你好呀);jedis.close();}Testvoid testRedisTemplate() {redisTemplate.opsForValue().set(rtKey,你好呀);}Testvoid testCrud() {final UserDto userDto UserDto.builder().id(IdUtil.getSnowflake().nextId()).name(用户1).gender(UserDto.Gender.MALE).build();userRepository.save(userDto);}}
http://www.zqtcl.cn/news/435839/

相关文章:

  • 网站与数据库的联系wordpress改为中文
  • 如何不让百度收录网站wix和wordpress比较
  • php开源网站 网上商城网站建设公司做销售好不好
  • 网站开发学哪种语言网站加水印
  • 帮人家做网站维护女性手机网站模板
  • 给一个企业做网站苏州网站备案查询
  • 域名备案期间怎么做网站广告投放行业
  • wordpress站内搜索统计网站突然不收录了
  • 网站源码小千个人网做网页设计一个月能挣多少
  • 贵州省建设厅公示网站广州seo网站推广费用
  • 旅游网站建设前期分析公众号制作多少钱
  • 延庆长沙网站建设怎样下载门户网站
  • flash 网站建设建设带数据搜索的网站
  • 设计网站网站名称云主机 小型网站
  • 网站建设方案书 模版公司制作网站收费标准
  • 福州企业网站html模板网站模板下载
  • 湛江自做网站城乡住建局官网
  • 广东网站建设找自己做网站还有出路吗
  • wordpress后台管理地址更改班级优化大师怎么用
  • 电脑网站开发学习产品怎么做市场推广
  • 上海市网站建设公叿目前流行的app网站开发模式
  • 企业手机网站建设效果wordpress栏目链接地址
  • 产品经理做网站网络公司名字免费起名大全
  • 做得比较好的公司网站kol营销
  • 百度指数分析平台长春seo优化企业网络跃升
  • 如何免费做网站域名wordpress 赚钱
  • 苏州市住房建设局网站首页温州网站设计公司
  • 网站模板哪个好用汕头建设工程总公司
  • iis网站重定向软件开发培训机构排名
  • 浙江大学教室办事大厅网站建设网页棋牌搭建