Maven MultiWAR项目:如何从根项目中部署它们?

时间:2013-02-23 19:39:34

标签: maven tomcat tomcat7 maven-3 maven-tomcat-plugin

我正在使用multimodule Maven项目。有些模块只是JAR,但有些模块是WAR(有时WAR是其他子模块的子模块)。

我正在使用tomcat插件的那些WAR模块。例如:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>tomcat-maven-plugin</artifactId>
            <version>1.1</version>
            <configuration>
                <server>my_local_tomcat</server>
                <path>/registration</path>
                <url>http://localhost:8080/manager/text</url>
            </configuration>
        </plugin>

现在我必须转到root,然后执行mvn clean install,然后进入包含WAR的子模块并为每个子模块执行mvn tomcat:redeploy

可以从根模块完成强制Maven查找WAR并重新部署吗?

1 个答案:

答案 0 :(得分:3)

在要部署的每个模块中,添加tomcat-deploy配置文件

  <profiles>
<profile>
  <id>tomcat-deploy</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <configuration>
          <server>my_local_tomcat</server>
          <path>/registration</path>
          <url>http://localhost:8080/manager/text</url>
        </configuration>
        <executions>
          <execution>
            <id>deploy-war</id>
            <phase>install</phase>
            <goals>
              <goal>deploy-only</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

现在运行:mvn install -Ptomcat-deploy