0

我有两个 oracle 用户,我正在为他们创建不同的模式。我的意思是每个模式都有不同的表、类型等。我想通过 flyway maven 插件创建两个模式,首先我有两个 maven 插件,但后来我也尝试了两个单独的配置文件:

<profiles>
    <profile>
      <id>database</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.googlecode.flyway</groupId>
            <artifactId>flyway-maven-plugin</artifactId>
            <configuration>
              <url>jdbc:oracle:thin:@devdb2:1521:ZOOMUTF</url>
              <table>SCHEMA_UPDATES</table>
              <outOfOrder>true</outOfOrder>
              <locations>
                <location>db/callrec</location>
              </locations>
              <user>cr_5199_mensik_mvn</user>
              <password>callrec</password>
              <serverId>callrec</serverId>
            </configuration>
            <executions>
              <execution>
                <id>compile</id>
                <phase>compile</phase>
                <goals>
                  <goal>migrate</goal>
                </goals>
              </execution>
              <execution>
                <id>clean</id>
                <phase>clean</phase>
                <goals>
                  <goal>clean</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>database_wbsc</id>
      <build>
        <plugins>

          <plugin>
            <groupId>com.googlecode.flyway</groupId>
            <artifactId>flyway-maven-plugin</artifactId>
            <configuration>
              <url>jdbc:oracle:thin:@devdb2:1521:ZOOMUTF</url>
              <table>SCHEMA_UPDATES</table>
              <outOfOrder>true</outOfOrder>
              <locations>
                <location>db/wbsc</location>
              </locations>
              <user>sc_5199_mensik_mvn</user>
              <password>wbsc</password>
              <serverId>wbsc</serverId>
            </configuration>
            <executions>
              <execution>
                <id>wbsc_compile</id>
                <phase>compile</phase>
                <goals>
                  <goal>migrate</goal>
                </goals>
              </execution>
              <execution>
                <id>wbsc_clean</id>
                <phase>clean</phase>
                <goals>
                  <goal>clean</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
</profiles>

然后我执行:

mvn clean -Pdatabase,database_wbsc

但结果是只有第二个配置文件被执行了两次:

[INFO] [clean:clean {execution: default-clean}]
[INFO] [flyway:clean {execution: clean}]
[INFO] Cleaned schema "sc_5199_mensik_mvn" (execution time 00:00.023s)
[INFO] [flyway:clean {execution: wbsc_clean}]
[INFO] Cleaned schema "sc_5199_mensik_mvn" (execution time 00:00.018s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------

如果我在 xml 中切换配置文件的顺序(而不是在 maven 执行命令中),则使用第二个用户。

如何执行两个配置文件但使用它们的配置?

4

1 回答 1

2

尝试在执行级别而不是插件级别提供配置。

            <plugin>
            <executions>
                <execution>
                    <id>execution1</id>
                    <configuration>
                    </configuration>
                </execution>
                <execution>
                    <id>execution2</id>
                    <configuration>
                    </configuration>
                </execution>
            </executions>
        </plugin>
于 2013-05-22T00:55:42.290 回答