【问题标题】:Using cargo maven plugin to start the server without artifact deployment使用 cargo maven 插件启动服务器,无需工件部署
【发布时间】:2015-06-14 02:43:28
【问题描述】:

我正在尝试使用 cargo maven 插件从 maven 启动 JBoss AS 7 服务器,而不执行任何部署。

我能够启动服务器,但正如我在 cargo pluging documentation 中看到的那样,如果项目的包装是 Java EE(WAR、EAR 等),目标 cargo:run 和 cargo:start 将自动部署当前项目。 ) 并且如果我没有在插件配置中使用可部署部分。

这是我在 pom 文件中的简单货物插件部分:

<plugins>
    ...
    <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven2-plugin</artifactId>
        <version>1.4.13</version>
        <configuration>

            <!-- Container configuration -->
            <container>
                <containerId>jboss73x</containerId>
                <home>${jboss-as.home}</home>
            </container>

        </configuration>
    </plugin>
    ...
</plugins>

由于我没有使用 deployables 并且项目打包是 war,所以当服务器启动时,cargo 会自动部署我的项目。

我想使用目标 cargo:run 来启动我的本地服务器而不部署任何项目工件。

cargo maven 插件可以吗?有什么想法或替代方案吗?

【问题讨论】:

    标签: maven maven-cargo cargo-maven2-plugin


    【解决方案1】:

    我认为,当您是可部署的存档项目时,可能无法要求插件不要部署配置它的项目。

    但是您可以做的是创建一个 pom 项目,其中没有源代码,只有 pom.xml,然后在该项目中运行您的货物插件。

    下面的示例在我运行目标 install 时启动和停止 cargo 插件:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>fr.fabien.perso</groupId>
        <artifactId>pom-project-tests</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>pom</packaging>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>start-container</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>start</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-container</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <container>
                            <type>embedded</type>
                        </container>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    

    【讨论】:

      【解决方案2】:

      是的 Yersan,可以在没有自建工件部署的情况下启动服务器。可以通过在项目的&lt;configuration&gt;标签上添加一个空的&lt;deployer /&gt;元素来实现。

      我在货物插件reference site 找到了信息。此外,我已经在本地项目中测试了配置,以确认它可以正常工作。

      【讨论】:

        猜你喜欢
        • 2017-10-01
        • 2015-05-21
        • 2011-06-11
        • 2012-04-02
        • 1970-01-01
        • 1970-01-01
        • 2014-07-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多