2

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

我可以启动服务器,但我可以在货物插件文档中阅读目标 cargo:run 和 cargo:start 如果项目的包装是 Java EE(WAR、EAR 等)并且如果我' m 不在插件配置中使用可部署部分。

这是我在 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>

由于我没有使用可部署项目并且项目打包是战争,所以当服务器启动时,货物会自动部署我的项目。

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

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

4

2 回答 2

2

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

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

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

<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>
于 2015-04-28T07:48:07.117 回答
0

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

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

于 2016-06-20T23:18:41.883 回答