当前位置: 首页 > 知识库问答 >
问题:

通过exec-maven-plugin运行2个主文件

宰父桐
2023-03-14

我想通过exec maven插件运行2个主配置文件。在我的生产中,我只使用“prod”配置文件,在我的持续集成中,我希望使用“prepod”配置文件和“prod”配置文件。

在产品

mvn-pprod

在连续集成中:

mvn-PpreProd, prod

<profiles>
    <profile>
        <id>preProd</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.5.0</version>
                        <executions>
                            <execution>
                                <id>CountContinusIntegr-execution</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <mainClass>com.mycompany.CountContinusIntegr</mainClass>
                        </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>prod</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.5.0</version>
                        <executions>
                            <execution>
                                <id>RunMyProd-execution</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <mainClass>com.mycompany.RunMyProd</mainClass>
                        </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

当我运行maven命令时,我有这个日志(com.mycompany.RunMyProd.main()运行2次):

[信息]——exec maven插件:1.5.0:java(CountContinusIntegr execution)@myproject-[2016-12-06 15:44:44]:读取文件场景。属性0[com.mycompany.RunMyProd.main()]信息。。。。[信息]——exec maven插件:1.5.0:java(RunMyProd执行)@myproject-[2016-12-06 15:44:45]:读取文件场景。属性0[com.mycompany.RunMyProd.main()]信息。。。。

共有1个答案

东门文斌
2023-03-14

我找到了解决方案我把

<profiles>
    <profile>
        <id>preProd</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.5.0</version>
                        <executions>
                            <execution>
                                <id>CountContinusIntegr-execution</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <mainClass>com.mycompany.CountContinusIntegr</mainClass>
                                </configuration>
                            </execution>
                        </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>prod</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.5.0</version>
                        <executions>
                            <execution>
                                <id>RunMyProd-execution</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <mainClass>com.mycompany.RunMyProd</mainClass>
                                </configuration>
                            </execution>
                        </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

 类似资料: