繁体   English   中英

在Maven pom.xml配置文件中执行Java Main类

[英]Executing Java Main class in Maven pom.xml profile

我可以使用以下命令使用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配置文件?

您是否尝试设置<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> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM