如何使用 maven 启动/停止 hsqldb



我正在尝试使用 maven 启动和停止 hsqldb。我想在测试阶段之前使用特定配置(数据库)启动 hsqldb 服务器,然后在之后停止它,并在应用程序启动之前和之后使用其他配置进行相同的操作。

目前我使用 maven exec 插件启动 hsqldb,但问题是服务器启动阻止了完整的 maven 构建过程(按 CTRL+C 停止服务器。也没有自动停止服务器的解决方案。

此致敬意

赫默罗克

检查我的hsqldb maven插件:https://github.com/avianey/hsqldb-maven-plugin

您可以像jetty-maven-plugin或tomee-maven-plugin一样启动/停止它:

<plugin>
    <!-- current version -->
    <groupId>fr.avianey.mojo</groupId>
    <artifactId>hsqldb-maven-plugin</artifactId>
    <version>1.0.0</version>
    <!-- 
        default value for in memory jdbc:hsqldb:hsql://localhost/xdb
        override only values you want to change
    -->
    <configuration>
        <driver>org.hsqldb.jdbcDriver</driver>
        <path>mem:test</path>
        <address>localhost</address>
        <name>xdb</name>
        <username>sa</username>
        <password></password>
        <validationQuery>SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS</validationQuery>
    </configuration>
    <!-- call start and stop -->
    <executions>
        <execution>
            <id>start-hsqldb</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
        <execution>
            <id>stop-hsqldb</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>

最新更新