0

我正在将我们的数据库管理转换为 Liquibase。这运行得很好。

作为后续步骤,我想确保所有未来的修改在部署到通用环境之前都经过测试,持续集成风格。我尝试使用以下设置执行此操作:

  • 构建包含 EJB Web 服务的耳朵
  • maven-embedded-glassfish-plugin用于在预集成测试 maven ohase 期间启动 Glassfish 3 的嵌入式 实例
    • 创建我的数据源作为开始目标的一部分
    • 在部署目标期间部署 ear
  • 仍然在预集成测试中,我在同一个数据库 URL 上运行 liquibase:update。在这种情况下,一个 H2 文件数据库
  • 然后我想在部署的应用程序上运行我们的 SoapUI 测试

但是当我走到这一步时,应用程序在数据库中找不到任何数据。所以问题是我是否在我的设置中遗漏了一些东西,或者是否有更好的方法来组织我的预期目标?

pom.xml,嵌入 Glassfish

  <plugin>
    <groupId>org.glassfish.embedded</groupId>
    <artifactId>maven-embedded-glassfish-plugin</artifactId>
    <version>4.0</version>
    <configuration>
      <ports>
        <http-listener>9090</http-listener>
        <https-listener>9191</https-listener>
      </ports>
      <goalPrefix>embedded-glassfish</goalPrefix>
      <app>${project.build.directory}/school-application-${project.version}.ear</app>
      <name>school-application</name>
      <commands>
        <command>create-jdbc-connection-pool --datasourceclassname=org.h2.jdbcx.JdbcDataSource --restype=javax.sql.DataSource --property URL=jdbc\:h2\:~/tmpLB\;AUTO_SERVER\=TRUE schoolDSPool</command>
        <command>create-jdbc-resource --connectionpoolid schoolDSPool jdbc/schoolDS</command>
      </commands>
    </configuration>
    <dependencies>
      <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.3.176</version>
      </dependency>
    </dependencies>
    <executions>
      <execution>
        <goals>
          <goal>start</goal>
          <goal>admin</goal>
          <goal>deploy</goal>
          <goal>undeploy</goal>
          <goal>stop</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

pom.xml,Liquibase

  <plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>3.1.1</version>
    <dependencies>
      <dependency>
        <groupId>company.school</groupId>
        <artifactId>school-db</artifactId>
        <version>${project.version}</version>
        <systemPath>../school-db/target</systemPath>
        <type>jar</type>
      </dependency>
      <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.3.176</version>
      </dependency>
    </dependencies>
    <executions>
      <execution>
        <phase>integration-test</phase>
        <configuration>
          <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
          <changeLogFile>db.changelog-master.xml</changeLogFile>
          <driver>org.h2.Driver</driver>
          <url>jdbc:h2:~/tmpLB;AUTO_SERVER=TRUE</url>
          <logging>info</logging>
        </configuration>
        <goals>
            <goal>update</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

我在目标表中插入数据的变更日志中有一个变更集。

  1. 我是否设置了正确的用户?
  2. 有没有办法在与 Glassfish 相同的进程中运行 Liquibase 并改用mem:数据库?

谢谢和问候,克里斯蒂安

4

1 回答 1

0

Ok, so there was an "easy" solution to the problem.

There was no data in the database since that changeset in liquibase changelog couldn't complete. I had the insert statements in a separate sql file that I called using the <sqlFile> liquibase tag. But the insert was violating some foreign key constraints and didn't get executed.

So what put me off was the fact that Liquibase seems to hide any errors from included sql files. Will try try reproduce that and Jira it if I succeed.

/Christian

于 2014-04-23T10:50:43.010 回答