【发布时间】:2019-01-09 17:53:47
【问题描述】:
我做了一个这样的项目:https://grokonez.com/spring-framework/spring-boot/use-spring-jpa-mysql-spring-boot 并正常运行
但是当我在 MYSQL 中用 column(name="id") 更改 "id" 时。我在邮递员上测试时出错。
{
"timestamp": 1533183310810,
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.transaction.UnexpectedRollbackException",
"message": "JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.",
"path": "/save"
}
我改变了一些客户类:
@Id
@Column(name="id")
private long id;
public Customer(long id , String firstName, String lastName){
this.id=id;
this.firstName=firstName;
this.lastName=lastName;
}
在 WebController 类中,我用 id、名字、姓氏保存了一个客户
@RequestMapping("/save")
public String process(){
repository.save(new Customer(1,"Jack", "Smith"));
return "Done";
}
如何用 id 保存客户?
【问题讨论】:
-
调试时,我看到错误:“ARJUNA016060: TransactionImple.enlistResource - 捕获:XAException.XAER_INVAL”
-
ConnectionImple.registerDatabase - ARJUNA017017:资源登记失败
-
和 ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - SynchronizationImple 失败
-
请将堆栈跟踪添加到您的问题中
标签: java mysql spring spring-boot mysql-workbench