gpt4 book ai didi

maven - 更改 Maven cargo 插件部署路径

转载 作者:行者123 更新时间:2023-12-01 01:31:21 27 4
gpt4 key购买 nike

我想让我的集成测试在 http://localhost:8080/messaging 上命中 Cargo 的 tomcat但是 cargo (cargo-maven2-plugin:1.0.5)更喜欢将我的消息传递项目部署为/messaging-0.0.7-SNAPSHOT,如在 tomcat 管理控制台和 target\tomcat6x\webapps 目录中所见。

所以我尝试将这些行添加到 cargo 配置中,认为它会选择默认 Artifact :

 <deployer>
<deployables>
<deployable>
<properties>
<context>/messaging</context>
</properties>
</deployable>
</deployables>
</deployer>

但事实并非如此。它甚至没有尝试,因为我在 target\tomcat6x\webapps 目录中没有看到消息或消息 0.0.7-SNAPSHOT。

当我像这样设置它时会发生同样的事情:
<configuration>
<type>standalone</type>
<wait>false</wait>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
</properties>
<deployer>
<deployables>
<deployable>
<groupId>com.company.platform</groupId>
<artifactId>messaging</artifactId>
<type>war</type>
<properties>
<context>/messaging</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>

这是完整的插件配置:
  <plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<type>standalone</type>
<wait>false</wait>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
</properties>
<deployer>
<deployables>
<deployable>
<properties>
<context>/messaging</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>

我的集成测试如下所示:
import junit.framework.TestCase;

import java.io.InputStream;
import java.net.URL;
import java.net.HttpURLConnection;
import java.sql.Time;

public class WebappTest extends TestCase
{
public void testCallIndexPage() throws Exception
{
URL url = new URL("http://localhost:8080/messaging/");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
assertEquals(200, connection.getResponseCode());
InputStream is = connection.getInputStream();
System.out.println(connection.getContent().getClass());

}
}

最好的方法是什么?知道它会成功部署为 hxxp://localhost:8080/messaging-0.0.7-SNAPSHOT,我可以更改测试,但是将 Artifact 版本拉入的快速方法是什么?

理想情况下,我希望 cargo 正确部署它,但不清楚如何部署。

最佳答案

来自 Cargo Plugin Reference ,

About WAR contexts

Many containers have their specific files for redefining context roots (Tomcat
has context.xml, JBoss has jboss-web.xml, etc.). If your WAR has such a file, the
server will most probably use the context root defined in that file instead of the
one you specify using the CARGO deployer.

你能解决这个问题吗?

另外,我认为上下文名称不应该有前导 / .

关于maven - 更改 Maven cargo 插件部署路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4729689/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com