gpt4 book ai didi

jpa - 无法回滚JPA事务; javax.persistence.PersistenceException : unexpected error when rollbacking"exceptions?

转载 作者:行者123 更新时间:2023-12-04 01:18:19 28 4
gpt4 key购买 nike

哪些事件导致“org.springframework.transaction.TransactionSystemException-无法回滚JPA事务;嵌套异常是javax.persistence.PersistenceException:回滚时发生意外错误”异常?

最佳答案

我在spring和Jpa上遇到了相同的错误。
问题是在超时情况下断开与Mysql数据库的连接。我在晚上没有使用应用程序,而在早晨,我遇到了同样的错误。当您不事件时,spring什么也不做,它会超时。
为了防止这种情况,您可以在application.properties中添加以下几行:

spring.datasource.connection-test-query="SELECT 1"
spring.datasource.test-while-idle=true
spring.datasource.test-on-borrow=true

现在工作正常。
来自 Virtustilus blog的其他信息也可能很有用。

关于jpa - 无法回滚JPA事务; javax.persistence.PersistenceException : unexpected error when rollbacking"exceptions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20556172/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com