Spring+redis集成redis缓存

  1、引入maven依赖

        <dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId><version>2.7.0</version></dependency><dependency><groupId>org.springframework.data</groupId><artifactId>spring-data-redis</artifactId><version>1.6.2.RELEASE</version></dependency>

2、配置文件redis.properties

#redis的配置文件
#服务的ip地址
redis.host=127.0.0.1
#服务器连接端口号
redis.port=6379
#服务器连接密码(默认为空)
redis.password=1234567
#连接超时时间(毫秒)
redis.timeout=3
#连接池中的最大连接数
redis.poolMaxTotal=10
#连接池中的最大空闲连接
redis.poolMaxIdle=10
#连接池中最大阻塞等待时间(使用负数表示没有限制)
redis.poolMaxWait=3
#最大空闲数,数据库连接的最大空闲时间。超过空闲时间,数据库连接将被标记为不可用,然后被释放。设为0表示无限制。  
redis.maxIdle=300
#连接池的最大数据库连接数。设为0表示无限制  
redis.maxActive=600
#最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。  
redis.maxWait=1000 
#在borrow一个jedis实例时,是否提前进行alidate操作;如果为true,则得到的jedis实例均是可用的;  
redis.testOnBorrow=true 

3、redis的配置bean的xml文件redis-config.xml

<beans	xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd"><!-- 引入配置文件 --><context:property-placeholder ignore-unresolvable="true" location="classpath:redis.properties"/><!-- redis连接池 --><bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">  <property name="maxIdle" value="${redis.maxIdle}" />  <property name="maxTotal" value="${redis.maxActive}" /><property name="testOnBorrow" value="${redis.testOnBorrow}" />  </bean><!-- redis连接池配置,类似于数据连接池 --><bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"><property name="hostName" value="${redis.host}"></property><property name="port" value="${redis.port}"></property><property name="password" value="${redis.password}"></property><property name="poolConfig" ref="jedisPoolConfig"></property></bean><!--redis操作模版,使用该对象可以操作redis  -->  <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" >    <property name="connectionFactory" ref="jedisConnectionFactory" />    <!--如果不配置Serializer,那么存储的时候缺省使用String,如果用User类型存储,那么会提示错误User can't cast to String!!  -->    <property name="keySerializer" >    <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />    </property>    <property name="valueSerializer" >    <bean class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer" />    </property>    <property name="hashKeySerializer">    <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>    </property>    <property name="hashValueSerializer">    <bean class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>    </property>    <!--开启事务  -->  <property name="enableTransactionSupport" value="true"></property>  </bean > </beans>

       注意:如果在多个spring配置文件中引入<context:property-placeholder .../>标签,最后需要加上ignore-unresolvable="true",否则会报错。

4、测试

       4.1基于RedisTemplate基本数据类型类

@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations = { "classpath:/redis-config.xml" })
@SuppressWarnings("all")
public class TestRedis {@SuppressWarnings("rawtypes")@Resource(name="redisTemplate")private RedisTemplate redisTemplate;@Testpublic void testRedis() {		//String读写redisTemplate.delete("myString");redisTemplate.opsForValue().set("myString","zhangsan");System.out.println(redisTemplate.opsForValue().get("myString"));System.out.println("---------------");//List读写redisTemplate.delete("myList");redisTemplate.opsForList().rightPush("myList","T");redisTemplate.opsForList().rightPush("myList", "A");redisTemplate.opsForList().leftPush("myList", "B");List<String> listCache  = redisTemplate.opsForList().range("myList", 0, -1);for (String str : listCache) {System.out.println(str);}System.out.println("---------------");//Set读写redisTemplate.delete("mySet");redisTemplate.opsForSet().add("mySet", "A");redisTemplate.opsForSet().add("mySet", "B");redisTemplate.opsForSet().add("mySet", "C");Set<String> set  = redisTemplate.opsForSet().members("mySet");for (String s : set) {System.out.println(s);}System.out.println("---------------");//Hash读写redisTemplate.delete("myHash");redisTemplate.opsForHash().put("myHash", "BJ", "北京");redisTemplate.opsForHash().put("myHash", "TJ", "天津");redisTemplate.opsForHash().put("myHash","HN","河南");Map<String,String> map = redisTemplate.opsForHash().entries("myHash");for (String key : map.keySet()) {System.out.println(map.get(key));}System.out.println("---------------");//ZSet读写redisTemplate.delete("myZSet");redisTemplate.opsForZSet().add("myZSet", "A",1);redisTemplate.opsForZSet().add("myZSet", "B",3);redisTemplate.opsForZSet().add("myZSet", "C",2);redisTemplate.opsForZSet().add("myZSet", "D",5);Set<String> zset = redisTemplate.opsForZSet().range("myZSet", 0, -1);for (String s : zset) {System.out.println(s);}}
}

       输出内容为:

zhangsan
---------------
B
T
A
---------------
A
B
C
---------------
河南
北京
天津
---------------
A
C
B
D

       4.2基于封装了RedisTemplate的基本数据类型类

             首先封装一个RedisTemplate的工具类

@Component
public class RedisUtil {@Autowired//(自动注入redisTemplet)private RedisTemplate<String, Object> redisTemplate;  public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) {  this.redisTemplate = redisTemplate;  }  //=============================common============================  /** * 指定缓存失效时间 * @param key 键 * @param time 时间(秒) * @return */  public boolean expire(String key,long time){  try {  if(time>0){  redisTemplate.expire(key, time, TimeUnit.SECONDS);  }  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 根据key 获取过期时间 * @param key 键 不能为null * @return 时间(秒) 返回0代表为永久有效 */  public long getExpire(String key){  return redisTemplate.getExpire(key,TimeUnit.SECONDS);  }  /** * 判断key是否存在 * @param key 键 * @return true 存在 false不存在 */  public boolean hasKey(String key){  try {  return redisTemplate.hasKey(key);  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 删除缓存 * @param key 可以传一个值 或多个 */  @SuppressWarnings("unchecked")  public void del(String ... key){  if(key!=null&&key.length>0){  if(key.length==1){  redisTemplate.delete(key[0]);  }else{  redisTemplate.delete(CollectionUtils.arrayToList(key));  }  }  }  //============================String=============================  /** * 普通缓存获取 * @param key 键 * @return 值 */  public Object get(String key){  return key==null?null:redisTemplate.opsForValue().get(key);  }  /** * 普通缓存放入 * @param key 键 * @param value 值 * @return true成功 false失败 */  public boolean set(String key,Object value) {  try {  redisTemplate.opsForValue().set(key, value);  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 普通缓存放入并设置时间 * @param key 键 * @param value 值 * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 * @return true成功 false 失败 */  public boolean set(String key,Object value,long time){  try {  if(time>0){  redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);  }else{  set(key, value);  }  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 递增 * @param key 键 * @param by 要增加几(大于0) * @return */  public long incr(String key, long delta){    if(delta<0){  throw new RuntimeException("递增因子必须大于0");  }  return redisTemplate.opsForValue().increment(key, delta);  }  /** * 递减 * @param key 键 * @param by 要减少几(小于0) * @return */  public long decr(String key, long delta){    if(delta<0){  throw new RuntimeException("递减因子必须大于0");  }  return redisTemplate.opsForValue().increment(key, -delta);    }    //================================Map=================================  /** * HashGet * @param key 键 不能为null * @param item 项 不能为null * @return 值 */  public Object hget(String key,String item){  return redisTemplate.opsForHash().get(key, item);  }  /** * 获取hashKey对应的所有键值 * @param key 键 * @return 对应的多个键值 */  public Map<Object,Object> hmget(String key){  return redisTemplate.opsForHash().entries(key);  }  /** * HashSet * @param key 键 * @param map 对应多个键值 * @return true 成功 false 失败 */  public boolean hmset(String key, Map<String,Object> map){    try {  redisTemplate.opsForHash().putAll(key, map);  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * HashSet 并设置时间 * @param key 键 * @param map 对应多个键值 * @param time 时间(秒) * @return true成功 false失败 */  public boolean hmset(String key, Map<String,Object> map, long time){    try {  redisTemplate.opsForHash().putAll(key, map);  if(time>0){  expire(key, time);  }  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 向一张hash表中放入数据,如果不存在将创建 * @param key 键 * @param item 项 * @param value 值 * @return true 成功 false失败 */  public boolean hset(String key,String item,Object value) {  try {  redisTemplate.opsForHash().put(key, item, value);  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 向一张hash表中放入数据,如果不存在将创建 * @param key 键 * @param item 项 * @param value 值 * @param time 时间(秒)  注意:如果已存在的hash表有时间,这里将会替换原有的时间 * @return true 成功 false失败 */  public boolean hset(String key,String item,Object value,long time) {  try {  redisTemplate.opsForHash().put(key, item, value);  if(time>0){  expire(key, time);  }  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 删除hash表中的值 * @param key 键 不能为null * @param item 项 可以使多个 不能为null */  public void hdel(String key, Object... item){    redisTemplate.opsForHash().delete(key,item);  }   /** * 判断hash表中是否有该项的值 * @param key 键 不能为null * @param item 项 不能为null * @return true 存在 false不存在 */  public boolean hHasKey(String key, String item){  return redisTemplate.opsForHash().hasKey(key, item);  }   /** * hash递增 如果不存在,就会创建一个 并把新增后的值返回 * @param key 键 * @param item 项 * @param by 要增加几(大于0) * @return */  public double hincr(String key, String item,double by){    return redisTemplate.opsForHash().increment(key, item, by);  }  /** * hash递减 * @param key 键 * @param item 项 * @param by 要减少记(小于0) * @return */  public double hdecr(String key, String item,double by){    return redisTemplate.opsForHash().increment(key, item,-by);    }    //============================set=============================  /** * 根据key获取Set中的所有值 * @param key 键 * @return */  public Set<Object> sGet(String key){  try {  return redisTemplate.opsForSet().members(key);  } catch (Exception e) {  e.printStackTrace();  return null;  }  }  /** * 根据value从一个set中查询,是否存在 * @param key 键 * @param value 值 * @return true 存在 false不存在 */  public boolean sHasKey(String key,Object value){  try {  return redisTemplate.opsForSet().isMember(key, value);  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 将数据放入set缓存 * @param key 键 * @param values 值 可以是多个 * @return 成功个数 */  public long sSet(String key, Object...values) {  try {  return redisTemplate.opsForSet().add(key, values);  } catch (Exception e) {  e.printStackTrace();  return 0;  }  }  /** * 将set数据放入缓存 * @param key 键 * @param time 时间(秒) * @param values 值 可以是多个 * @return 成功个数 */  public long sSetAndTime(String key,long time,Object...values) {  try {  Long count = redisTemplate.opsForSet().add(key, values);  if(time>0) expire(key, time);  return count;  } catch (Exception e) {  e.printStackTrace();  return 0;  }  }  /** * 获取set缓存的长度 * @param key 键 * @return */  public long sGetSetSize(String key){  try {  return redisTemplate.opsForSet().size(key);  } catch (Exception e) {  e.printStackTrace();  return 0;  }  }  /** * 移除值为value的 * @param key 键 * @param values 值 可以是多个 * @return 移除的个数 */  public long setRemove(String key, Object ...values) {  try {  Long count = redisTemplate.opsForSet().remove(key, values);  return count;  } catch (Exception e) {  e.printStackTrace();  return 0;  }  }  //===============================list=================================  /** * 获取list缓存的内容 * @param key 键 * @param start 开始 * @param end 结束  0 到 -1代表所有值 * @return */  public List<Object> lGet(String key,long start, long end){  try {  return redisTemplate.opsForList().range(key, start, end);  } catch (Exception e) {  e.printStackTrace();  return null;  }  }  /** * 获取list缓存的长度 * @param key 键 * @return */  public long lGetListSize(String key){  try {  return redisTemplate.opsForList().size(key);  } catch (Exception e) {  e.printStackTrace();  return 0;  }  }  /** * 通过索引 获取list中的值 * @param key 键 * @param index 索引  index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 * @return */  public Object lGetIndex(String key,long index){  try {  return redisTemplate.opsForList().index(key, index);  } catch (Exception e) {  e.printStackTrace();  return null;  }  }  /** * 将list放入缓存 * @param key 键 * @param value 值 * @param time 时间(秒) * @return */  public boolean lSet(String key, Object value) {  try {  redisTemplate.opsForList().rightPush(key, value);  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 将list放入缓存 * @param key 键 * @param value 值 * @param time 时间(秒) * @return */  public boolean lSet(String key, Object value, long time) {  try {  redisTemplate.opsForList().rightPush(key, value);  if (time > 0) expire(key, time);  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 将list放入缓存 * @param key 键 * @param value 值 * @param time 时间(秒) * @return */  public boolean lSet(String key, List<Object> value) {  try {  redisTemplate.opsForList().rightPushAll(key, value);  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 将list放入缓存 * @param key 键 * @param value 值 * @param time 时间(秒) * @return */  public boolean lSet(String key, List<Object> value, long time) {  try {  redisTemplate.opsForList().rightPushAll(key, value);  if (time > 0) expire(key, time);  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }  /** * 根据索引修改list中的某条数据 * @param key 键 * @param index 索引 * @param value 值 * @return */  public boolean lUpdateIndex(String key, long index,Object value) {  try {  redisTemplate.opsForList().set(key, index, value);  return true;  } catch (Exception e) {  e.printStackTrace();  return false;  }  }   /** * 移除N个值为value  * @param key 键 * @param count 移除多少个 * @param value 值 * @return 移除的个数 */  public long lRemove(String key,long count,Object value) {  try {  Long remove = redisTemplate.opsForList().remove(key, count, value);  return remove;  } catch (Exception e) {  e.printStackTrace();  return 0;  }  }  }

测试上面封装的类是否好用

@RunWith(SpringJUnit4ClassRunner.class)//这个地方因为在工具类上加了注解,所以需要引入spring的配置文件
@ContextConfiguration(locations = { "classpath:/redis-config.xml" , "classpath*:/spring-mybatis.xml"})
public class TestRedisUtils {@Autowiredprivate RedisUtil redisUtil;@Testpublic void testRedisUtils() {String  str = "string";//1.字符串List<String> list = new ArrayList<String>();//listlist.add("0");list.add("中国");list.add("2");Set<String> set = new HashSet<String>();//setset.add("0");set.add("中国");set.add("2");Map<String, Object> map = new HashMap();//mapmap.put("key1", "str1");map.put("key2", "中国");map.put("key3", "str3");//删除数据,可以删除多个redisUtil.del("list","str","set","map");//1.字符串操作redisUtil.set("str", str);redisUtil.expire("str", 120);//指定失效时间为2分钟String str1 = (String) redisUtil.get("str");System.out.println(str1);//2.list操作redisUtil.lSet("list", list);redisUtil.expire("list", 120);//指定失效时间为2分钟List<Object> list1 = redisUtil.lGet("list", 0, -1);System.out.println(list1);//3.set操作redisUtil.sSet("set", set);redisUtil.expire("set", 120);//指定失效时间为2分钟Set<Object> set1 = redisUtil.sGet("set");System.out.println(set1);//3.map操作redisUtil.hmset("map", map);redisUtil.expire("map", 120);//指定失效时间为2分钟Map<Object, Object> map1 = redisUtil.hmget("map");System.out.println(map1);}
}

        输出结果:

string
[[0, 中国, 2]]
[[0, 2, 中国]]
{key3=str3, key1=str1, key2=中国}

       4.3基于封装了RedisTemplate的javaBean类

        首先创建java Bean--Student,需要一个默认无参的构造方法且类上面需要序列化,否则会报错

//序列化很重要
public class Student implements Serializable{/*** */private static final long serialVersionUID = 1L;private int age;private String name;private Date birthday;//没有这个会报错public Student() {}public Student(int age, String name, Date birthday) {this.age = age;this.name = name;this.birthday = birthday;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Date getBirthday() {return birthday;}public void setBirthday(Date birthday) {this.birthday = birthday;}@Overridepublic String toString() {return "Student [age=" + age + ", name=" + name + ", birthday=" + birthday + "]";}
 编写测试javaBean的方法
@RunWith(SpringJUnit4ClassRunner.class)//这个地方因为在工具类上加了注解,所以需要引入spring的配置文件
@ContextConfiguration(locations = { "classpath:/redis-config.xml" , "classpath*:/spring-mybatis.xml"})
public class TestRedisBean {@Autowiredprivate RedisUtil redisUtil;@Testpublic void testRedisBean() {List<Student> list = new ArrayList<Student>();//listlist.add(new Student(20,"张三list",new Date()));list.add(new Student(21,"李四list",new Date()));list.add(new Student(22,"王五list",new Date()));Set<Student> set = new HashSet<Student>();//listset.add(new Student(20,"张三set",new Date()));set.add(new Student(21,"李四set",new Date()));set.add(new Student(22,"王五set",new Date()));Map<String, Object> map = new HashMap();//mapmap.put("key1",new Student(20,"张三set",new Date()));map.put("key2",new Student(21,"李四set",new Date()));map.put("key3",new Student(22,"王五set",new Date()));redisUtil.del("list","set","map");//1.list操作redisUtil.lSet("list", list,1200);List<Object> list1 = redisUtil.lGet("list", 0, -1);System.out.println(list1);//3.set操作redisUtil.sSet("set", set);redisUtil.expire("set", 1200);//指定失效时间为2分钟Set<Object> set1 = redisUtil.sGet("set");System.out.println(set1);//3.map操作redisUtil.hmset("map", map);redisUtil.expire("map", 120);//指定失效时间为2分钟Map<Object, Object> map1 = redisUtil.hmget("map");System.out.println(map1);}

       输出结果为:

[[Student [age=20, name=张三list, birthday=Fri Aug 02 17:22:55 GMT+08:00 2019], Student [age=21, name=李四list, birthday=Fri Aug 02 17:22:55 GMT+08:00 2019], Student [age=22, name=王五list, birthday=Fri Aug 02 17:22:55 GMT+08:00 2019]]]
[[Student [age=20, name=张三set, birthday=Fri Aug 02 17:22:55 GMT+08:00 2019], Student [age=21, name=李四set, birthday=Fri Aug 02 17:22:55 GMT+08:00 2019], Student [age=22, name=王五set, birthday=Fri Aug 02 17:22:55 GMT+08:00 2019]]]
{key2=Student [age=21, name=李四set, birthday=Fri Aug 02 17:22:55 GMT+08:00 2019], key1=Student [age=20, name=张三set, birthday=Fri Aug 02 17:22:55 GMT+08:00 2019], key3=Student [age=22, name=王五set, birthday=Fri Aug 02 17:22:55 GMT+08:00 2019]}

参考博客:https://www.cnblogs.com/qlqwjy/p/8562703.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/52346.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

vue 报错

报错 npm install 报错:code ELIFECYCLE errno 1 This is probably not a problem with npm. There is Vue前端项目用npm install 报错:code ELIFECYCLE errno 1 This is probably not a problem with npm. There is

深入理解Linux内核--Ext2和Ext3文件系统

Ext2的一般特征 类Unix操作系统使用多种文件系统。尽管所有这些文件系统都有少数POSIX API(如state())所需的共同的属性子集&#xff0c;但每种文件系统的实现方式是不同的。 Linux的第一个版本是基于MINIX文件系统的。当Linux成熟时&#xff0c;引入了扩展文件系统(Extended …

Java smslib包开发

上一篇文章我详细介绍RXTXcomm的安装方法和简单代码,如果小伙伴涉及到需要使用手机短信模块完成短信收发需求的话,可以使用到smslib进行开发。 首先还是同样的,将整个smslib包源码导入项目,并且将它所需依赖一起进行导入 导入完成之后,我们就可以对smslib包进行二次开发了 下面…

2023 CCPC 华为云计算挑战赛 hdu7399 博弈,启动!(图上博弈/枚举+逆向有向图sg函数)

题目 给定t(t<200)组样例&#xff0c; 每次给定一个n(n<300)个左边的点m(m<300)个右边的点的二分图&#xff0c;图无重边 所有边总量不超过5e5 初始时棋子可以被放置在任意一个点上&#xff0c; 若被放置在左边&#xff0c;则Alice先走&#xff1b;被放置在右边&a…

SensorService中Binder案例

SensorService中Binder案例 1、FWK实际操作在Native层2、Native层中代码实现Bn/Bp端2.1 代码实现Bn端2.2 代码实现Bp端2.2.1 模板interface_cast android12-release 1、FWK实际操作在Native层 SensorService.java实际操作Native层SensorService.cpp&#xff1b;对应Bn服务端。 …

微信小程序 车牌号输入组件

概述 一个小组件&#xff0c;用于方便用户输入车牌号码 详细 概述 有时候我们开发过程中会遇到需要用户输入车牌号的情况&#xff0c;让客户通过自带键盘输入&#xff0c;体验不好且容易出错&#xff0c;例如车牌号是不能输入O和I的&#xff0c;因此需要有一个自定义的键盘…

vue直接使用高德api

第一步&#xff1a;在index.html 引入 <script src"https://webapi.amap.com/maps?v2.0&key你的key"></script>第二步&#xff1a;在你需要地图的时候 放入 <template><div style"width: 200px; height: 200px"><div id&q…

极狐GitLab 价值流管理之「总时间图」使用指南

本文来源&#xff1a;about.gitlab.com 作者&#xff1a;Haim Snir 译者&#xff1a;极狐(GitLab) 市场部内容团队 对于软件研发管理者来说&#xff0c;了解在整个研发过程中时间都耗费在了哪些地方&#xff0c;是进行交付价值优化的关键洞察。GitLab / 极狐GitLab 新的价值流分…

Linux操作系统--CentOS使用初体验

我们安装好Linux的操作系统之后,下面就可以使用Linux操作系统了。我们一起来看看如何使用。 (1).桌面 我们在进入CentOS操作系统后可以发现一些和Windows操作系统相类似的情况。如:网络、时间显示、以及基本的软件等内容。 --创建文件、文件夹。 (2).操作终端 Linux中的终…

【vue 3.0 中使用vue-router详细步骤】

Vue 3.0 中使用 vue-router 的步骤如下&#xff1a; 1. 安装 vue-router&#xff1a;2. 创建一个单独的文件&#xff1a;3.main.js 配置路由&#xff1a;4. 在 App.vue 中使用 <router-view> 组件&#xff1a;5. 在路由的组件中使用 <router-link> 组件进行导航&am…

回归预测 | MATLAB实现PSO-RBF粒子群优化算法优化径向基函数神经网络多输入单输出回归预测(多指标,多图)

回归预测 | MATLAB实现PSO-RBF粒子群优化算法优化径向基函数神经网络多输入单输出回归预测&#xff08;多指标&#xff0c;多图&#xff09; 目录 回归预测 | MATLAB实现PSO-RBF粒子群优化算法优化径向基函数神经网络多输入单输出回归预测&#xff08;多指标&#xff0c;多图&a…

创建和分析二维桁架和梁结构研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

Git基础——基本的 Git本地操作

本文涵盖了你在使用Git的绝大多数时间里会用到的所有基础命令。学完之后&#xff0c;你应该能够配置并初始化Git仓库、开始或停止跟踪文件、暂存或者提交更改。我们也会讲授如何让Git忽略某些文件和文件模式&#xff0c;如何简单快速地撤销错误操作&#xff0c;如何浏览项目版本…

Spring详解

文章目录 一、引言1.1 原生web开发中存在哪些问题&#xff1f; 二、Spring框架2.1 概念2.2 访问与下载 三、Spring架构组成四、自定义工厂4.1 配置文件4.2 工厂类 五、构建Maven项目5.1 新建项目5.2 选择Maven目录5.3 GAV坐标 六、Spring环境搭建6.1 pom.xml中引入Spring常用依…

【sql】MongoDB 增删改查 高级用法

【sql】MongoDB 增删改查 高级用法 相关使用文档 MongoDB Query API — MongoDB Manual https://www.mongodb.com/docs/manual/reference/sql-comparison //增 //新增数据2种方式 db.msg.save({"name":"springboot&#x1f600;"}); db.msg.insert({&qu…

prompt工程(持续更新ing...)

诸神缄默不语-个人CSDN博文目录 我准备想办法把这些东西整合到我的ScholarEase项目里。到时候按照分类、按照prompt生成方法列一堆选项&#xff0c;用户自己生成prompt后可以选择在ScholarEase里面聊天&#xff0c;也可以复制到别的地方&#xff08;比如ChatGPT网页版之类的&a…

【官方中文文档】Mybatis-Spring #SqlSessionFactoryBean

SqlSessionFactoryBean 在基础的 MyBatis 用法中&#xff0c;是通过 SqlSessionFactoryBuilder 来创建 SqlSessionFactory 的。而在 MyBatis-Spring 中&#xff0c;则使用 SqlSessionFactoryBean 来创建。 设置 要创建工厂 bean&#xff0c;将下面的代码放到 Spring 的 XML …

C#设计模式六大原则之--迪米特法则

设计模式六大原则是单一职责原则、里氏替换原则、依赖倒置原则、接口隔离原则、迪米特法则、开闭原则。它们不是要我们刻板的遵守&#xff0c;而是根据实际需要灵活运用。只要对它们的遵守程度在一个合理的范围内&#xff0c;努为做到一个良好的设计。本文主要介绍一下.NET(C#)…

Redisson自定义序列化

Redisson自定义序列化_redisson 序列化_yzh_1346983557的博客-CSDN博客 redis存取的数据一定是可序列化的&#xff0c;而可序列化方式可以自定义。如果不同客户端设置的可序列化方式不一样&#xff0c;会导致读取不一致的问题。常见的序列化方式有几下几种

Ansible 使用 RHEL 系统角色

安装 RHEL 系统角色软件包&#xff0c;并创建符合以下条件的 playbook /home/greg/ansible/timesync.yml 在所有受管节点上运行 使用 timesync 角色 配置该角色&#xff0c;以使用当前有效的 NTP 提供商 配置该角色&#xff0c;以使用时间服务器 172.25.254.254 配置该角色&am…