在Eclipse中,如何运行修改上下文路径的Tomcat Maven插件

问题描述 投票:0回答:2

在安装了 m2 Maven 插件的 Eclipse 中。我可以使用“Run on Server”命令通过 Eclipse WTP 在 Tomcat 中运行我的 Web 应用程序。

现在我想通过Maven修改上下文路径,所以我使用以下插件:

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <version>1.1</version>
        <configuration>
          <path>${contextpath-name}</path>
        </configuration>
</plugin>

那么如何在 Eclipse 中运行这个插件呢?使用 Eclipse WTP 总是给我以下 URL -

http://localhost:8080/myapp

我知道我可以在独立的 Maven 上运行该插件,但我想知道如何在 Eclipse 中运行

maven tomcat plugins
2个回答
10
投票

假设

我假设您已经安装了 Maven for eclipse 的插件。

安装

在项目资源管理器中选择项目时,选择 Run --> Run As --> Maven Install

运行Tomcat

转到“运行”-->“运行配置”..

添加新的 Maven 构建

命名进程,选择将部署为 war 的基本目录

设置目标 --> tomcat:run (这是 Tomcat 的默认目标)

按照以下步骤,您可以通过 Eclipse 部署所有内容。

玩得开心。 :)


0
投票

有了Maven,就非常简单了。只需添加此属性与所需的上下文路径:

<properties>
   <m2eclipse.wtp.contextRoot>put-the-context-here</m2eclipse.wtp.contextRoot>
</properties>
© www.soinside.com 2019 - 2024. All rights reserved.