在Maven pom.xml配置文件

时间:2017-05-25 09:39:05

标签: java maven jenkins

我可以使用maven命令行使用以下命令启动我的应用程序:

mvn -f test-framework/pom.xml exec:java -Dexec.mainClass="com.application.app" -Dexec.classpathScope="test" -Dexec.args="/META-INF/spring/application-context.xml" -Denv=stubbed -Dsys=app -Dspring.profiles.active=app

我想修改项目的pom.xml,以便在使用Jenkins的测试作业期间自动启动应用程序。 我想知道如何将上面的Maven命令转换为Maven配置文件。我已完成以下操作,但应用程序无法启动:

                    <execution>
                        <id>start-app</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>mvn</executable>
                            <workingDirectory>${sut.path}/app/test-framework</workingDirectory>
                            <arguments>
                                <argument>exec:java</argument>
                                <argument>"-Dexec.mainClass=com.application.app"</argument>
                                <argument>"-Dexec.classpathScope=test"</argument>
                                <argument>"-Dexec.args=/META-INF/spring/application-context.xml"</argument>
                                <argument>-Denv=stubbed</argument>
                                <argument>-Dsys=app</argument>
                                <argument>-Dspring.profiles.active=pdc</argument>
                            </arguments>
                        </configuration>
                    </execution>

任何人都可以帮助我如何将命令发送到pom.xml配置文件中?

1 个答案:

答案 0 :(得分:0)

您是否尝试过设置<start-class>属性?

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <start-class>com.stackoverflow.MyClass</start-class>
    </properties>