Tomcat 的 IntelliJ 运行配置 - 预配置应用程序上下文

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

当我想部署一个具有非ROOT上下文路径的java web项目时,我可以配置它。

手动方式:

  • 在 Eclipse 中:
    • 通过项目属性
      • 转到 Web 项目设置
      • 在那里进行配置
    • 通过服务器视图
      • 双击服务器
      • 转到模块
      • 在那里编辑
  • 在 IntelliJ 的 Tomcat 服务器中运行配置
    • 部署选项卡
    • 添加你想要的神器
    • 编辑应用程序上下文

在 Maven 等时代,这应该是自动化的,所以不是每次部署/取消部署 Web 应用程序时我都必须再次编辑它。 或者每当新开发人员加入该项目时。

现在对于 Eclipse,您可以在 pom 中设置一个属性,告诉它使用哪个路径:

<properties>
    <m2eclipse.wtp.contextRoot>/my/custom/context/path</m2eclipse.wtp.contextRoot>
</properties>

IntelliJ 有等效的吗?


java eclipse maven tomcat intellij-idea
1个回答
0
投票

IntelliJ IDEA 与 maven 集成得很好,这种情况下只要按照 Apache Tomcat 官方推荐就可以解决问题:

/META-INF/context.xml 是 Tomcat 特定的配置文件。它用于配置如何将应用程序部署到 Tomcat,其中包括应用程序所在的上下文路径。

<Context docBase="yourAppName" path="/yourAppPath" reloadable="true">

https://tomcat.apache.org/tomcat-7.0-doc/html-manager-howto.html#Deploy_using_a_Context_configuration_%22.xml%22_file

© www.soinside.com 2019 - 2024. All rights reserved.