IntelliJ IDEA:Maven,项目编译与部署 [英] IntelliJ IDEA: Maven, project compilation and deployment

查看:36
本文介绍了IntelliJ IDEA:Maven,项目编译与部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我解释一下IntelliJ IDEA的编译、部署和打包maven项目的工作流程?

Can someone explain me IntelliJ IDEA's workflow of compilation, deployment and packaging with binded maven project ?

我在通过IDEA的调试模式启动tomcat服务器时遇到了一些误解.例如,我有一个工件 - 战争档案.据我了解,当我运行调试模式时 - IDEA 重新编译并将更改的代码更新为战争存档.

I've encountered some misunderstanding when I'm starting tomcat server via IDEA's debug mode. For example I have one artifact - war archive. As I understand when I'm running debug mode - IDEA recompiles and updates changed code into war-archive.

但是打包的 maven artifact 会发生什么?IntelliJ 会更新它吗?或者我必须设置Buld maven before startup"选项以确保更改的代码将上传到环境中?

But what happens with packaged maven artifact ? Does IntelliJ updates it ? Or I have to set 'Buld maven before startup' option to be sure that changed code will be uploaded to environment ?

推荐答案

Intelli J 不使用 maven 来构建项目,它使用自己的构建过程.它使用 pom 文件作为项目的描述.

Intelli J doesn't use maven to build the project it uses its own build process. It uses the pom file as a description of the project.

这意味着几件事,如果您想在 tomcat 中运行时构建诸如 war 文件之类的工件,那么您所要做的就是告诉 IntelliJ 在运行/调试配置"对话框中构建战争.IntelliJ 将自动构建您在运行/调试配置的部署选项卡下指定的任何工件.因此,如果您指定爆炸战争,它将构建爆炸战争,如果您指定常规战争,它将构建常规战争.

This means a couple of things, if you want to build an artifact such as a war file when running in tomcat then all you have to do is tell IntelliJ to build the war in the Run/Debug Configurations dialog. IntelliJ will automatically build any artifacts you specify under the deployment tab of your run/debug configuration. So if you specify the exploded war it will build the exploded war, if you specify the regular war it will build the regular war.

有时人们需要运行自定义插件或构建目标,在这种情况下,您可以配置 IntelliJ 以运行自定义 Maven 目标.

Occasionally people need to run custom plugins or build targets in which case you can configure IntelliJ to run the custom maven goals.

您还可以告诉 intellIJ 运行 maven 包目标而不是构建工件.IntelliJ 会将目标目录下的任何内容部署到 tomcat.

You can also tell intellIJ to run the maven package goal rather than build the artifact. IntelliJ will deploy whatever is under the target directory to tomcat.

重要的一点是 IntellIJ 使用两个独立的构建系统.您需要告诉每个构建系统要做什么.并且您需要告诉 IntelliJ 使用哪个构建系统.默认情况下,一旦导入项目,IntelliJ 将使用它自己的构建系统,除非您告诉它使用 maven 做某事.

The important take away is IntellIJ is using two separate build systems. You need to tell each build system what to do. And you need to tell IntelliJ which build system to use for what. IntelliJ will by default use it's own build system once a project has been imported, unless you tell it to use maven for something.

虽然 IntelliJ 将构建您在 pom 文件中指定的工件,但它不会执行诸如部署工件存储库(本地或其他方式)之类的操作,除非您单击 Maven 工具窗口中的部署目标.

While IntelliJ will build the artifact you specify in the pom file it won't do things like deploy them your artifact repository (local or other wise) unless you click on the deploy target in the Maven tools window.

此外,如果您更改了 pom 文件并且没有启用自动重新导入,那么在您单击 Maven 工具窗口中的强制重新导入选项之前,这些更改不会反映在您的项目中.

Also if you change your pom file and don't have auto re-import enabled those changes won't be reflected in your project until you click the force re-import option from the maven tools window.

这篇关于IntelliJ IDEA:Maven,项目编译与部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆