spring controller 单例如何保证并发安全
controller默认是单例的,不要使用非静态的成员变量,否则会发生数据逻辑混乱。
正因为单例所以不是线程安全的。
我们下面来简单的验证下:
package com.riemann.springbootdemo.controller;
import org.springframework.context.annotation.Scope;
import org.springframew...
转载
2020-05-05 21:40:45 ·
838 阅读 ·
0 评论