作者:zdl | 来源:互联网 | 2023-02-12 16:49
CansomeoneexplainmeIntelliJIDEAsworkflowofcompilation,deploymentandpackagingwithbinded
Can someone explain me IntelliJ IDEA's workflow of compilation, deployment and packaging with binded maven project ?
有人能解释一下IntelliJ IDEA的捆绑式maven项目的编译,部署和打包工作流程吗?
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.
当我通过IDEA的调试模式启动tomcat服务器时,我遇到了一些误解。例如,我有一个工件 - 战争存档。据我所知,当我运行调试模式时 - IDEA重新编译并将更改的代码更新为war-archive。
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 ?
但是打包的maven工件会发生什么? IntelliJ会更新吗?或者我必须在启动前设置'Buld maven'选项以确保更改的代码将上传到环境中?
2 个解决方案
61
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.
Intelli J不使用maven来构建它使用自己的构建过程的项目。它使用pom文件作为项目的描述。
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.
这意味着一些事情,如果你想在tomcat中运行时构建诸如war文件之类的工件,那么你所要做的就是告诉IntelliJ在Run / Debug Configurations对话框中构建war。 IntelliJ将自动构建您在运行/调试配置的部署选项卡下指定的任何工件。因此,如果你指定爆炸战争,它将构建爆炸战争,如果你指定常规战争,它将建立常规战争。
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目标。
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运行maven包目标而不是构建工件。 IntelliJ会将目标目录下的任何内容部署到tomcat。
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正在使用两个独立的构建系统。您需要告诉每个构建系统要做什么。而且你需要告诉IntelliJ哪个构建系统用于什么。一旦项目被导入,IntelliJ将默认使用它自己的构建系统,除非你告诉它使用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.
虽然IntelliJ将构建您在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.
此外,如果您更改了pom文件并且未启用自动重新导入,则在您从maven工具窗口单击强制重新导入选项之前,这些更改不会反映在您的项目中。