public class useraccount {
//用户id
private string userid;
//账户内金额
private int amount;
//添加账户金额
public void addamount(int amount) {
this.amount = this.amount amount;
}
// 省略构造方法和getter/setter
}
创建一个线程实现类accountoperationthread:
public class accountoperationthread implements runnable {
private final static logger logger = loggerfactory.getlogger(accountoperationthread.class);
private static final long release_success = 1l;
private string userid;
private redistemplate
其中redistemplate的实例化交给了spring boot:
@configuration
public class redisconfig {
@bean
public redistemplate redistemplate(redisconnectionfactory redisconnectionfactory) {
redistemplate redistemplate = new redistemplate<>();
redistemplate.setconnectionfactory(redisconnectionfactory);
jackson2jsonredisserializer