首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更改maven cargo插件部署路径

更改maven cargo插件部署路径
EN

Stack Overflow用户
提问于 2011-01-19 06:19:02
回答 3查看 4.7K关注 0票数 5

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

因此,我尝试将这些行添加到cargo配置中,计算出它将获得默认工件:

代码语言:javascript
复制
 <deployer>
  <deployables>
   <deployable>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
 </deployer>

它甚至没有尝试这样做,因为我在target\tomcat6x\webapps目录中看不到消息或消息-0.0.7-快照。

当我像这样设置它时,同样的事情也会发生:

代码语言:javascript
复制
<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>

下面是完整的插件配置:

代码语言:javascript
复制
  <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>

我的集成测试如下所示:

代码语言:javascript
复制
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,后,我可以更改测试,但是有什么方法可以快速引入工件版本呢?

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

EN

回答 3

Stack Overflow用户

发布于 2011-01-19 10:36:46

来自Cargo Plugin Reference

代码语言:javascript
复制
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.

你能解决这个问题吗?

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

票数 2
EN

Stack Overflow用户

发布于 2016-12-22 00:18:38

Deployables标签不应该放在Deployer标签中:

代码语言:javascript
复制
  <deployables>
   <deployable>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
票数 2
EN

Stack Overflow用户

发布于 2012-08-27 15:47:23

如何设置finalName属性呢?

如果你在你的POM中设置了<finalName>messaging</finalName>,这应该可以解决这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4729689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档