state-machine持久化踩坑
发表于|更新于
|浏览量:
植物借栽培而生育,人类借教育而成人。——罗素
今天使用spring-state-machine踩坑了,这里配了持久化,然后在事件里更改了额外数据
1 | gameInfo = stateMachine.getExtendedState().get(WordChainConst.GAME_INFO, GameInfo.class); |
结果在interceptor或者guard等其他地方使用的时候,却获取不到正确的值
原来在修改值后,还需要持久化保存一下。。。
1 | public class RedisSmPersister extends AbstractStateMachinePersister<StateEnum, EventEnum, String> |
1 | redisSmPersister.persist(sm, sm.getId()); |
相关推荐
2023-03-09
JOOL
感官并不欺骗人,欺骗人的是判断力——歌德 分享一个框架JOOL https://github.com/jOOQ/jOOL 其封装了更好用的lambda 例如: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119// (1, 2, 3, 4, 5, 6)Seq.of(1, 2, 3).concat(Seq.of(4, 5, 6));// trueSeq.of(1, 2, 3, 4).contains(2);// trueSeq.of(1, 2, 3, 4).containsAll(2, 3);// trueSeq.of(1, 2, 3,...
2020-12-22
springbootTest坑
人一能之,己百之;人十能之,己千之。——《中庸》 今天踩到一个坑,使用springboot单元测试时插入数据回滚了 最后发现原来需要在测试类上面加上@Rollback(false)就可以了 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960package com.ruben;/** * @ClassName: MybatisPlusDemo * @Date: 2020/11/9 0009 20:51 * @Description: */import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;import com.baomidou.mybatisplus.core.metadata.IPage;import com.baomidou.mybatisplus.core.toolkit.Wrappers;import co...
2023-05-03
为shenyu的PortUtils.findPort添加单元测试
爱好自由是人的天性,但往往过度而陷于放纵。斯宾诺莎 今天为shenyu的shenyu-client-core模块下添加了PortUtils.findPort的test case: https://github.com/apache/shenyu/pull/4604 对应的代码如下: 123456789101112131415161718192021222324252627282930313233343536373839404142/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Ve...
2022-10-28
r2dbc指定时区问题
政治能把一个人突然变老——巴尔扎克 今天看见这个警告 我的配置项如下: 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import cn.hutool.core.util.StrUtil;import com.alibaba.druid.util.JdbcUtils;import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties;import io.r2dbc.spi.ConnectionFactories;import io.r2dbc.spi.ConnectionFactory;import io.r2dbc.spi.ConnectionFactoryOption...
2023-12-17
spring-doc报错Unable to render this definition
心情愉快是肉体和精神的最佳卫生法。——乔治·桑 原因:自己修改了ByteArrayHttpMessageConverter的顺序。。。 解决方案: OpenAPI 3 Library for spring-boot 13.79. Why am i getting an error: Swagger UI unable to render definition, when overriding the default spring registered HttpMessageConverter?When overriding the default spring-boot registered HttpMessageConverter, you should have ByteArrayHttpMessageConverter registered as well to have proper springdoc-openapi support. 12converters.add(new ByteArrayHttpMessageConverter());converters...
2021-02-19
replaceAll坑
学如弓弩,才如箭镞,识以领之,方能中鹄。一一袁枚 前两天遇到一个坑,在使用String.replace()和replaceAll的时候 因为没有看过API和注释,拿着就开用,结果造成一个bug 这里留做记录 场景是这样的,我对一个字符串进行替换,将[idea]替换为""时使用了replaceAll,导致其他不该被替换的字符也被替换了 这段代码 123String str = "Hino Supa and ruben";System.out.println(str.replace("[idea]", ""));System.out.println(str.replaceAll("[idea]", "")); 输出的结果为 12Hino Supa and rubenHno Sup n rubn 可以看到,replaceAll把我们的[idea]当做了正则表达式… 点进源码一看注释,好家伙 第一句就是 123Replaces each substring of...

阿超
我的名字叫阿超 年龄25岁 家在北京市 职业是软件开发 每天最晚也会在八点前回家 不抽烟 酒浅尝辄止 晚上十二点上床 保证睡足八个小时 睡前写一篇博客 再做二十分钟俯卧撑暖身 然后再睡觉 基本能熟睡到天亮 像婴儿一样不留下任何疲劳和压力 就这样迎来第二天的早晨 健康检查结果也显示我很正常 我想说明我是一个不论何时都追求内心平稳的人 不拘泥于胜负 不纠结于烦恼 不树立使我夜不能寐的敌人 这就是我在这社会的生活态度
Follow Me公告
This is my Blog