【问题标题】:Change BTM tlog file location更改 BTM tlog 文件位置
【发布时间】:2016-02-25 09:52:26
【问题描述】:

我们使用org.codehaus.btm:btm:2.1.4 进行测试,我们看到这些文件出现在我们的 maven 模块目录(即工作目录)中:

  • btm1.tlog
  • btm2.tlog

我希望在另一个目录中创建它们,例如在 target/btmlogs/ 中。我该如何配置 BTM 来做到这一点?

【问题讨论】:

    标签: java jta bitronix


    【解决方案1】:

    您必须配置 TransactionManager。 Relevant part of the configuration

    在名为src/main/resources/bitronix-default-config.properties 的文件中执行此操作。像这样的:

    # Avoid warnings in test log
    bitronix.tm.serverId=foo-bar
    # Disable tlog files
    bitronix.tm.journal=null
    # In case the journal is enabled locally, avoid that the btm1.tlog and btm2.tlog files are created in the module's directory
    # causing gitignore, mvn clean and IDE indexing issues
    bitronix.tm.journal.disk.logPart1Filename=target/btm/btm1.tlog
    bitronix.tm.journal.disk.logPart2Filename=target/btm/btm2.tlog
    

    【讨论】:

    • poolingDataSource.getDriverProperties().setProperty("bitronix.tm.journal.disk.logPart1Filename", "target/btm/my-btm1.tlog"); 导致bitronix.tm.utils.PropertyException: no readable property 'bitronix' in class 'bitronix.tm.resource.jdbc.lrc.LrcXADataSource'
    • 改用TransactionManagerServices.getConfiguration(),会导致IllegalStateException: cannot change the configuration while the transaction manager is running。在静态构造函数中而不是在每个 JUnit 测试开始时执行它们会使除第一个测试之外的所有测试都写入错误的目录(因此忽略该属性)。
    • 已修复。我已经添加了在答案中添加这些道具的文件:bitronix-default-config.properties。
    猜你喜欢
    • 2013-10-12
    • 1970-01-01
    • 1970-01-01
    • 2021-04-28
    • 2010-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多