启动一个Web容器,然后使用Cargo maven2插件部署战争

发布于 2024-10-03 23:11:59 字数 2305 浏览 0 评论 0原文

我尝试使用 Cargo-maven2-plugin 来自动化我的 WAR 模块部署以进行测试。

我想知道如何启动tomcat服务器(预装在我的机器中)并自动将我的war部署到启动的服务器上?

Cargo 项目的文档提到,cargo:start 目标可以可选部署可部署项:

http://cargo.codehaus.org/Maven2+plugin#Maven2plugin-gettingstarted< /a>

cargo:start 启动一个容器。该任务可以选择安装和配置容器;它还可以选择向其部署可部署项(WAR、EAR 等)。

但是,我不知道如何启用此选项以使其在运行 Cargo:start 时部署可部署项。

这是我当前的 pom 配置:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.0</version>
            <configuration>
                <wait>true</wait>
                <container>
                    <containerId>tomcat6x</containerId>
                    <home>${tomcat.home}</home>
                </container>
                <configuration>
                    <type>standalone</type>
                    <home>target/tomcat6x</home>
                </configuration>
                <deployer>
                    <deployables>
                        <deployable>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>my-war</artifactId>
                            <type>war</type>
                        </deployable>
                    </deployables>
                </deployer>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>my-war</artifactId>
        <version>${project.version}</version>
        <type>war</type>
    </dependency>
</dependencies>

当我运行“mvn Cargo:start”时,Tomcat 服务器将启动,但是,my-war 可部署项不会被部署。我必须从另一个 shell 运行“mvn Cargo:deploy”来部署这场战争。

I tried to use cargo-maven2-plugin to automate my WAR module deployment for testing.

I wonder how can I start the tomcat server (pre-installed in my machine) and deploy my war to the started server automatically?

Documentation from Cargo project mentions that cargo:start goal can optionally deploy deployables:

http://cargo.codehaus.org/Maven2+plugin#Maven2plugin-gettingstarted

cargo:start Start a container. That task can optionally install and configure a container; it can also optionally deploy deployables (WAR, EAR, etc.) to it.

However, I have no idea how to enable this option to make it deploy deployables when running cargo:start.

Here is my current pom configuration:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.0</version>
            <configuration>
                <wait>true</wait>
                <container>
                    <containerId>tomcat6x</containerId>
                    <home>${tomcat.home}</home>
                </container>
                <configuration>
                    <type>standalone</type>
                    <home>target/tomcat6x</home>
                </configuration>
                <deployer>
                    <deployables>
                        <deployable>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>my-war</artifactId>
                            <type>war</type>
                        </deployable>
                    </deployables>
                </deployer>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>my-war</artifactId>
        <version>${project.version}</version>
        <type>war</type>
    </dependency>
</dependencies>

When I run "mvn cargo:start", the tomcat server will be started, however, the my-war deployable won't be deployed. And I have to run "mvn cargo:deploy" from another shell to deploy this war.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

榕城若虚 2024-10-10 23:11:59

好的 - 这里发生了一些事情:

1)您提到 Tomcat 服务器已预先安装在计算机上,但您仍然在目标目录中指定了目录。这不是一个好主意,因为在 mvn clean 后它会被清除。

2) 对于预安装的 Tomcat,您没有在部署程序配置中将 type 设置为 existing

3)你的上下文定义在哪里?您是否有上下文片段文件,或者您是否在 WAR 的 WEB-INF 目录中使用 tomcat.xml 文件?

最重要的是,配置错误的组合阻碍了您。发布更新的 Maven 配置和有关 XML 上下文定义的附加详细信息,我可以为您提供进一步帮助。

OK -- There are a few things going on here:

1) You mention that the Tomcat server is pre-installed on the machine, but yet you have the directory specified in your target directory. This is not a good idea as that will get wiped out after a mvn clean.

2) For pre-installed Tomcat you are not setting the type to existing inside the deployer configuration.

3) Where is your context definition? Do you have a context fragment file or are you using a tomcat.xml file inside the WEB-INF directory in the WAR?

Bottom line a combination of configuration errors are holding you back. Post an updated Maven configuration and addition details about the XML context definition and I can help you further.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文