изменение пути развертывания грузового плагина maven

Я хочу, чтобы мой интеграционный тест попал на tomcat груза по адресу http://localhost:8080/messaging, но груз (cargo- maven2-plugin:1.0.5) предпочитает развертывать мой проект обмена сообщениями как /messaging-0.0.7-SNAPSHOT, как показано в консоли администратора tomcat и в каталоге target\tomcat6x\webapps.

Поэтому я попытался добавить эти строки в конфигурацию груза, полагая, что он подберет артефакт по умолчанию:

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

но это не так. Он даже не пытается, так как я не вижу сообщения или сообщения-0.0.7-SNAPSHOT в каталоге target\tomcat6x\webapps.

То же самое происходит, когда я настроил его так:

<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>

My integration test looks like this:

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, я мог бы изменить тест, но как быстро получить версию артефакта?

В идеале хотелось бы, чтобы груз развернулся правильно, но непонятно как.


person dols    schedule 18.01.2011    source источник


Ответы (3)


Из Справочник по подключаемым модулям Cargo,

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.

Не могли бы вы столкнуться с этой проблемой?

Кроме того, я думаю, что имя контекста не должно начинаться с /.

person Raghuram    schedule 19.01.2011
comment
Это было не так. Есть web.xml, но нет context.xml - person dols; 20.01.2011

Тег Deployables не должен находиться внутри тега Deployer:

  <deployables>
   <deployable>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
person ftkg    schedule 21.12.2016

Как насчет установки свойства finalName?

Если вы установите <finalName>messaging</finalName> в своем POM, это должно сработать.

person Roberto Lo Giacco    schedule 27.08.2012