【问题标题】:Maven : How to generate project's war file in two foldersMaven:如何在两个文件夹中生成项目的war文件
【发布时间】:2011-06-10 07:29:44
【问题描述】:

我希望当我运行 mvn install 时,可以在 /target 中生成一个战争,并在 c:..tomcat 6\deploy 目录中生成另一个战争。 我正在使用 maven2、Eclipse 和 m2eclipse。这该怎么做 ?? 谢谢 :)

【问题讨论】:

    标签: eclipse maven m2eclipse


    【解决方案1】:

    您可以尝试使用maven-antrun-plugin 将您的战争复制到tomcat 部署目录,如下所示:

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <configuration>
                            <target>
                                <copy file="{project.build.directory}/${project.actifactId}-${project.version}.war" tofile="<your tomcat path>/${project.actifactId}-${project.version}.war" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    

    【讨论】:

      【解决方案2】:

      如果您尝试Maven Jetty Plugin,也许您不需要复制战争文件。此插件用于直接从 Maven 运行 Web 应用程序。

      【讨论】:

      • 我不想运行它,我想将它放置到 liferay-tomcat-bundle 的部署文件夹中以进行热部署:)
      【解决方案3】:

      试试cargo-maven2-plugin。可能这样的事情会起作用:

      <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven2-plugin</artifactId>
        <executions>
          <execution>
            <id>deploy-local</id>
            <phase>install</phase>
            <goals>
              <goal>deployer-deploy</goal>
            <goals>
          </execution>
        </executions>
        <configuration>
          <container>
            <containerId>tomcat6x</containerId>
          </container>
          <configuration>
            <type>existing</type>
            <home>/your/tomcat/dir</home> <!-- replace as needed -->
          </configuration>
        </configuration>
      </plugin>
      

      ... 将其放入个人资料或顶级 &lt;build&gt;&lt;plugins&gt; 部分,看看它是否适合您...

      【讨论】:

      • 如何指明我的 .war 文件的名称?因为不是项目名+版本?
      • 我认为默认情况下它将使用您声明的finalName 值。但我不完全确定。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-04
      • 2017-11-02
      • 1970-01-01
      • 2022-10-14
      • 1970-01-01
      相关资源
      最近更新 更多