使用Maven pom.xml将War文件部署到Tomcat根目录

Dom*_*nik 2 eclipse tomcat web-applications pom.xml maven

假设以下pom.xmlmaven将构建一个client.war文件,当部署到Tomcat时,该文件将具有URLwww.server.com:8080/client/

需要更改什么才能在服务器根目录下访问应用程序www.server.com:8080/

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>...</groupId>
    <artifactId>client</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>...</name>
    <url>http://maven.apache.org</url>
    <build>
        <resources>
            <resource>
                <directory>target/generated-resources</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            ...
        </plugins>
        <finalName>client</finalName>
    </build>
...
</project>
Run Code Online (Sandbox Code Playgroud)

use*_*849 8

我相信如果你愿意,你可以离开名为client.war的战争.然后配置tomcat6插件,设置如下路径:

<plugin>
  <groupId>org.apache.tomcat.maven</groupId>
  <artifactId>tomcat6-maven-plugin</artifactId>
  <version>2.0-beta-1</version>
      <!-- put the configuration in an execution if you want to... -->
      <configuration>
        <path>/</path>
        <warFile>${project.build.directory}/client.war</warFile>
        <!-- other config options here -->
      </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我没有使用tomcat7版本的插件,但我猜它是类似的.