【问题标题】:DBUnit Current thread was interruptedDBUnit 当前线程被中断
【发布时间】:2014-01-14 12:04:40
【问题描述】:

我正在使用 maven dbunit 插件(调整版本 1.0-beta-3)。

在我的pom.xml 文件中,我定义了一些执行次数很少的插件:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>dbunit-maven-plugin</artifactId>
    <!--jar file that has the jdbc driver -->
    <dependencies>
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>${postgresql.version}</version>
        </dependency>
    </dependencies>
    <configuration>
        <driver>org.postgresql.Driver</driver>
        <dataTypeFactoryName>org.dbunit.ext.postgresql.PostgresqlDataTypeFactory</dataTypeFactoryName>
        <useQualifiedTableNames>true</useQualifiedTableNames>
    </configuration>
    <executions>
        <!-- INSERTS -->
        <execution>
            <id>RequestDaoIT</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>operation</goal>
            </goals>
            <configuration>
                <url>jdbc:postgresql://${db.host}:${db.port}/${db.name}</url>
                <username>${db.username}</username>
                <password>${db.password}</password>
                <format>flat</format>
                <type>INSERT</type>
                <src>src/test/resources/dbunit/RequestDaoIT.xml</src>
            </configuration>
        </execution>
        <execution>
            <id>SlotDaoIT</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>operation</goal>
            </goals>
            <configuration>
                <url>jdbc:postgresql://${db.host}:${db.port}/${db.name}</url>
                <username>${db.username}</username>
                <password>${db.password}</password>
                <format>flat</format>
                <type>INSERT</type>
                <src>src/test/resources/dbunit/SlotDaoIT.xml</src>
            </configuration>
        </execution>
        ... CUT

mvn verify 构建期间第二次执行时出现以下错误:

[ERROR] Failed to execute goal org.codehaus.mojo:dbunit-maven-plugin:1.0-XXXX:operation (SlotDaoIT) on project xxx-xxxxx-xxxxxx: Error executing database operation: INSERT: Current thread was interrupted (Thread=Thread[main,5,main]): NullPointerException -&gt; [Help 1]

谁能告诉我可能出了什么问题?我在 SO 或谷歌的任何地方都找不到它。谢谢!

【问题讨论】:

  • 刚刚发现了一个错误,即那些插入应该在pre-integration-test 阶段执行。会再跑一次。

标签: java postgresql maven dbunit


【解决方案1】:

作为参考,我发布了解决方案,这导致了我这个问题。在 flat-xml 数据文件 SlotDaoIT.xml 中,我有错误的起始 XML 元素:

<xxx.dataset>

不仅仅是:

<dataset>

哦,糟糕的复制粘贴习惯......

【讨论】:

    猜你喜欢
    • 2010-09-26
    • 1970-01-01
    • 2018-07-27
    • 1970-01-01
    • 2014-05-11
    • 2022-10-14
    • 2018-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多