Maven:如何在两个文件夹中生成项目的war文件

发布于 2024-11-14 17:05:09 字数 136 浏览 3 评论 0原文

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

I want that when I run the mvn install, a war can be generated in the /target and an other war in the c:....tomcat 6\deploy directory.
I'm using maven2, Eclipse and m2eclipse. How to do this ??
Thnx :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝礼 2024-11-21 17:05:09

您可以尝试使用 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>

You could try to use the maven-antrun-plugin to copy your war to the tomcat deploy directory like this:

<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>
梦晓ヶ微光ヅ倾城 2024-11-21 17:05:09

Maybe you don't need to copy the war file if you try the Maven Jetty Plugin. This plugin is for running a web application directly from Maven.

吾性傲以野 2024-11-21 17:05:09

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

...将其放入配置文件或顶级 部分,看看它是否适合您...

Try the cargo-maven2-plugin. Probably something like this would work:

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

... slap that into a profile or the top-level <build><plugins> section and see if it works for you ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文