public static String getUuid() {
String s = UUID.randomUUID().toString();
// 去掉"-"符號的UUID
return s.replace("-", "").trim();
}數據庫
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)//針對數據庫 主鍵自動增加的
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid",strategy="uuid")//使用uuid的主鍵註解 dom
使用UUID 出現detached entity passed to persist 這種錯誤是由於你的主鍵id已經有值了 因此報錯 在jsp頁面不要定義他namejsp