从IDE部署多模块maven项目到Tomcat
我有一个多模块 Maven 项目,其中 pom 具有以下打包类型
pom
|--jar
|--jar
|--war
war 项目依赖于 jar 项目。我想这是使用 Maven 构建的 Web 应用程序的一个非常典型的设置。 部署和调试项目
- 我可以通过运行
mvn install
- 将战争复制到 Tomcat 来
- 以调试模式启动 Tomcat
- ,从 IDE
,将远程调试器连接到 Tomcat显然,在每次更改后执行这些步骤,很快就变成了疼痛。是否有更简单的方法来构建项目并将其部署到 Tomcat,以便可以从 IDE 进行调试?欢迎提供有关 Eclipse 或 IntelliJ(最好是两者)的说明。
为了以防万一,我通常使用 m2eclipse 插件创建 Eclipse 项目文件。在 intelliJ 中,我使用导入 Maven 项目功能。
谢谢。
I have a mutil-module Maven project wherein the pom's have the following packaging types
pom
|--jar
|--jar
|--war
The war project depends on jar projects. I imagine this is a pretty typical setup for a webapp built with Maven. I can deploy and debug the project by
- running
mvn install
- copying the war to Tomcat
- starting Tomcat in debug mode
- from the IDE, connecting the remote debugger to Tomcat
Obviously, performing these steps after every change, quickly becomes a pain. Is there a simpler way to build and deploy the project to Tomcat, such that it can be debugged from the IDE? Instructions for either Eclipse or IntelliJ (ideally both), would be welcome.
In case it makes any difference, I normally create the Eclipse project files using the m2eclipse plugin. In intelliJ I use the import maven project feature.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
tomcat:run-war-only 怎么样?
How about tomcat:run-war-only?
m2e介于maven和eclipse之间(这里不涉及Tomcat)。选择“自动构建”(确保“问题”选项卡下没有任何内容。如果有,只需从“问题”选项卡中删除错误条目)。这将编译所有内容并将其转换为 .class 文件。
wtp是在eclipse和tomcat(一般是服务器)之间进行部署。
m2e-wtp就像一个桥梁,用于在tomcat中部署maven项目
m2e is between maven and eclipse (Tomcat is not involved here). Choose "Build Automatically" (make sure there is nothing under "Problems" tab. If it is,just delete the errors entry from "Problems" tab). This will compiler and convert everything to .class files.
wtp is between eclipse and tomcat (servers in general) for deployment.
m2e-wtp is like a bridge used for deployment of maven projects in tomcat
如果您安装 m2eclipse-extras (wtp 支持),您将能够配置 tomcat 服务器在 Eclipse 中并从 Eclipse 中部署应用程序。这还将监视项目的更改并自动重新部署。如果是大型应用程序,这可能效果不佳。
另一种方法是使用 maven jetty 插件或 maven tomcat 插件,将其作为 Web 应用程序运行,而不需要构建战争。
您还可以查看 jrebel (商业工具),它可以加载对类文件/配置的更改,而无需需要重新部署。
If you install the m2eclipse-extras (wtp support) you will be able to configure tomcat server within eclipse and deploy the applications from within eclipse. This will also watch the project for changes and automatically redeploy. This might not work well if it is a large application.
The other approach is to use the maven jetty plugin or the maven tomcat plugin that runs it as a web-app without requiring to build a war.
You can also look at jrebel (a commercial tool) that can load the changes to class files / cofiguration without requiring a redeployment.