Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven SQL插件在多模块项目中多次运行_Java_Maven - Fatal编程技术网

Java Maven SQL插件在多模块项目中多次运行

Java Maven SQL插件在多模块项目中多次运行,java,maven,Java,Maven,我有一个多模块项目,如下所示: Module |_________sub-module1 | |___pom.xml |_________sub-module2 | |___pom.xml |_________sub-module3 |

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

            Module
            |_________sub-module1
            |                   |___pom.xml          
            |_________sub-module2
            |                   |___pom.xml
            |_________sub-module3
            |                   |___pom.xml
            |_________sub-module4
            |                   |___pom.xml
            |_________pom.xml
我在子模块2中添加了一些用于创建和删除集成测试数据的sql脚本2。在父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>

org.codehaus.mojo
SQLMaven插件
net.sourceforge.jtds
jtds
1.3.1
net.sourceforge.jtds.jdbc.Driver
jdbc:jtds:sqlserver:blah
sqlsrv集成测试信条
假的
创建集成测试数据
过程测试资源
执行
提升
${basedir}/src/test/resources
创建-integration-test-data.sql
测试后下降db
整合后测试
执行
${basedir}/src/test/resources
drop-integration-test-data.sql
现在,当我运行
mvn clean install
时,我得到一个错误,即文件不存在于子模块1中。所以我尝试将脚本添加到子模块1。现在,它在子模块1中执行,但也在子模块2子模块3中执行,在那里它失败了,因为脚本不在子模块3中

如何使脚本只执行一次?

在注释中回答:


在需要的地方添加SQLMaven插件(子模块2),然后 不在父级中,因为它将被继承,当然也将被继承 在每个孩子身上执行khmarbaise 2014年7月22日9:25


在需要的地方(子模块2)添加SQLMaven插件,而不是在父模块中,因为它将被继承,当然会在每个子模块中执行。