【问题标题】:How to start/stop hsqldb using maven?如何使用 maven 启动/停止 hsqldb?
【发布时间】:2013-01-09 09:30:13
【问题描述】:

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

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

最好的问候

紫苏

【问题讨论】:

  • 抱歉,这并不能解决任何问题。我没有使用休眠,我不想使用源代码启动/停止 hsqldb,我想使用 Maven 启动/停止它。

标签: java maven hsqldb


【解决方案1】:

检查我的 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>

【讨论】:

  • 它在 maven Central 中有 0 个用法,但集成测试包含在世界上几乎每个 Java 企业项目中。所以,这个插件绝对不能用! (除了一个宠物项目)但是,不幸的是,我们看到即使在宠物项目中也没有人想要它。
猜你喜欢
  • 2010-12-13
  • 2011-04-23
  • 2012-01-13
  • 2011-03-02
  • 2012-11-06
  • 2017-12-24
  • 2011-09-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多