[英]changing maven cargo plugin deployment path
我希望我的集成測試能夠在http:// localhost:8080 / messaging上找到貨物的tomcat,但貨物(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>
但事實並非如此。 它甚至沒有嘗試,因為我沒有在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,我可以改變測試,但是什么是拉動工件版本的快速方法?
理想情況下,我想讓貨物正確部署它,但目前還不清楚如何。
從貨物插件參考 ,
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.
你能解決這個問題嗎?
另外,我認為上下文名稱不應該具有前導/
。
設置finalName屬性怎么樣?
如果在POM中設置<finalName>messaging</finalName>
,這應該可以解決問題。
Deployables
標簽不應該進入Deployer
標簽:
<deployables>
<deployable>
<properties>
<context>/messaging</context>
</properties>
</deployable>
</deployables>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.