简体   繁体   English

改变maven货物插件部署路径

[英]changing maven cargo plugin deployment path

I want to have my integration test hit cargo's tomcat at http://localhost:8080/messaging but cargo (cargo-maven2-plugin:1.0.5) prefers to deploy my messaging project as /messaging-0.0.7-SNAPSHOT, as seen in the tomcat admin console and in the target\\tomcat6x\\webapps directory. 我希望我的集成测试能够在http:// localhost:8080 / messaging上找到货物的tomcat,但货物(cargo-maven2-plugin:1.0.5)更愿意将我的消息传递项目部署为/messaging-0.0.7-SNAPSHOT,如在tomcat管理控制台和target \\ tomcat6x \\ webapps目录中看到。

So I tried adding these lines to the cargo config, figuring that it will pick up the default artifact: 所以我尝试将这些行添加到货物配置中,确定它将获取默认工件:

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

but it doesn't. 但事实并非如此。 It doesn't even attempt to since I don't see the messaging or messaging-0.0.7-SNAPSHOT in the target\\tomcat6x\\webapps directory. 它甚至没有尝试,因为我没有在target \\ tomcat6x \\ webapps目录中看到消息或消息-0.0.7-SNAPSHOT。

The same thing happens when I set it up like so: 当我这样设置时,会发生同样的事情:

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

Here's the full plugin config: 这是完整的插件配置:

  <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());

    }
}

What's the best way to proceed? 什么是最好的方法? Knowing that it will successfully deploy as hxxp://localhost:8080/messaging-0.0.7-SNAPSHOT, I could alter the test, but what would be a quick way to pull the artifact version in? 知道它将成功部署为hxxp:// localhost:8080 / messaging-0.0.7-SNAPSHOT,我可以改变测试,但是什么是拉动工件版本的快速方法?

Ideally, I'd like to have cargo deploy it correctly, but it is unclear how. 理想情况下,我想让货物正确部署它,但目前还不清楚如何。

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

Could you be hitting this issue? 你能解决这个问题吗?

Also, I think context name should not have a leading / . 另外,我认为上下文名称不应该具有前导/

What about setting the finalName property? 设置finalName属性怎么样?

If you set <finalName>messaging</finalName> in your POM this should do the trick. 如果在POM中设置<finalName>messaging</finalName> ,这应该可以解决问题。

Deployables tag should not go inside Deployer tag: Deployables标签不应该进入Deployer标签:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM