我希望在Spring控制器中生成UUID。由于我对此很陌生,所以我正在研究以下内容:
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String corrId;
我不希望将这个 UUID 与任何数据库列/字段相关联,但希望它是唯一的(我不确定是否可能实现)。
当我尝试打印字符串“corrId”的值时,它总是返回 null。
我也尝试过,但 corrId 的值仍然是 null。
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String corrId;
这里我做错了什么,或者我的方法完全错误。谢谢提前!