gpt4 book ai didi

java - Maven SQL-Plugin 在多模块项目中多次运行

转载 作者:太空宇宙 更新时间:2023-11-04 06:39:29 24 4
gpt4 key购买 nike

我有一个多模块项目,如下所示:

            Module
|_________sub-module1
| |___pom.xml
|_________sub-module2
| |___pom.xml
|_________sub-module3
| |___pom.xml
|_________sub-module4
| |___pom.xml
|_________pom.xml

我在子模块2中添加了一些用于创建和删除集成测试数据的sql脚本。在父 pom 中,我有以下代码来设置集成测试的数据库。

    <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>

<configuration>
<driver>net.sourceforge.jtds.jdbc.Driver</driver>
<url>jdbc:jtds:sqlserver:blah</url>
<settingsKey>sqlsrv-integration-test-creds</settingsKey>
<skip>false</skip>
</configuration>

<executions>

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

</executions>

</plugin>

现在,当我运行 mvn clean install 时,我收到错误消息,指出该文件在 sub-module1 中不存在。所以我尝试将脚本添加到 sub-module1 中。现在,它在 sub-module1 中执行,但也在 sub-module2sub-module3 中执行,但由于脚本不在 sub-module3 中,因此失败。

如何让脚本只执行一次?

最佳答案

在评论中回答:

Add the sql-maven-plugin exactly where you need it (sub-module-2) and not in the parent, cause it will be inherited and of course will be executed within every child. – khmarbaise Jul 22 '14 at 9:25

关于java - Maven SQL-Plugin 在多模块项目中多次运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24879163/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com