繁体   English   中英

了解Maven构建过程

[英]Understanding the Maven Build Process

我有一个正在为学校工作的项目,该项目正在使用hibernate进行jpa实现。 我的问题是,如果我在休眠属性文件中关闭了模式生成,并且想要手动更新模式(我的ddl文件)并让该模式随应用程序一起部署,我需要在<build></build>标记将架构作为部署内容的一部分?

在src / main / resources下,我有一个ddl目录,其中包含表创建脚本。

在构建过程中,您将需要使用sql-maven-plugin执行sql

就像是

<build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>sql-maven-plugin</artifactId>
        <version>1.5</version>

        <dependencies>
          <!-- specify the dependent jdbc driver here -->
          <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>8.1-407.jdbc3</version>
          </dependency>
        </dependencies>

        <!-- common configuration shared by all executions -->
        <configuration>
          <driver>org.postgresql.Driver</driver>
          <url>jdbc:postgressql://localhost:5432:yourdb</url>
          <username>postgres</username>
          <password>password</password>
          <!-- You can comment out username/password configurations and
               have maven to look them up in your settings.xml using ${settingsKey}
          -->
          <settingsKey>sensibleKey</settingsKey>
          <!--all executions are ignored if -Dmaven.test.skip=true-->
          <skip>${maven.test.skip}</skip>
        </configuration>

        <executions>
          <execution>
            <id>create-data</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>execute</goal>
            </goals>
            <configuration>
              <orderFile>ascending</orderFile>
              <fileset>
                <basedir>${basedir}</basedir>
                <includes>
                  <include>src/test/sql/test-data2.sql</include>
                </includes>
              </fileset>
            </configuration>
          </execution>

      </plugin>
      [...]
    </plugins>
    [...]
  </build>

根据您的数据库更改配置

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM