【问题标题】:how to specify default pessimistic_write lock timeout in yaml?如何在 yaml 中指定默认的 pessimistic_write 锁定超时?
【发布时间】:2021-09-24 03:52:40
【问题描述】:

我想在获取数据库行的悲观写锁时指定锁超时值。我发现可以在hibernate或者jpa xml属性文件中这样指定persistence.xml:

<properties>
   <property name="javax.persistence.query.timeout" value="3000"/>
</properties>

如何为 spring boot 的 application.yml 文件实现相同的功能?

以下不起作用

spring:
    datasource:
        url: jdbc:mysql://localhost:3306/testing
        username: test
        password: test123
    jpa:
        show-sql: true
        javax.persistence.lock.timeout: 1000  #DOESN'T WORK

【问题讨论】:

    标签: spring-boot hibernate spring-data-jpa


    【解决方案1】:

    刚刚发现它在 jpa:hibernate 下指定时有效,而不仅仅是 jpa:

    spring:
      datasource:
        url: jdbc:mysql://localhost:3306/testing
        username: test
        password: test123
      jpa:
        show-sql: true
        hibernate:
          ddl-auto: update
          javax.persistence.lock.timeout: 2000 #WORKS!
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-10
      • 2021-02-06
      • 2018-08-15
      • 1970-01-01
      • 2023-02-02
      • 2015-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多