简体   繁体   English

如何在 pom.xml 中将 maven jar 更新为战争

[英]How to update maven jar to war in pom.xml

I'm currently studying maven and I just made "maven-archetype-quickstart" and set the compile properties to 1.8我目前正在研究 maven,我刚刚制作了“maven-archetype-quickstart”并将编译属性设置为 1.8

Then I wanted to change the jar to war so I changed packaging to war.然后我想把 jar 改成战争,所以我把包装改成了战争。

I also checked Build, Execution, Deployment -> Build Tools -> Maven -> Import Maven projects automatically我还检查了Build, Execution, Deployment -> Build Tools -> Maven -> Import Maven projects automatically

and I've tried Maven -> Reimport All Maven Projects but the projects structure doesn't change.我已经尝试过Maven -> Reimport All Maven Projects ,但项目结构没有改变。 How can I update the maven package 'jar' to 'war'?如何将 maven package 'jar' 更新为 'war'?

在此处输入图像描述

The project structure in IntelliJ reflects the stucture of folders/files in the filesystem. IntelliJ 中的项目结构反映了文件系统中文件夹/文件的结构。 That shouldn't change.那不应该改变。 More precisely, both jar and war packaged modules are allowed to have src/main/java , src/main/resources , src/test/java , src/test/resources更准确地说, jarwar打包模块都允许有src/main/javasrc/main/resourcessrc/test/javasrc/test/resources

This is a standard maven layout.这是标准的 maven 布局。

However, in addition WAR projects can have src/main/webapp folder where you can place JSP files, web.xml descriptor (inside inner WEB-INF folder) and so on.但是,除此之外,WAR 项目可以有src/main/webapp文件夹,您可以在其中放置WEB-INF文件、 web.xml描述符(在内部文件夹内)

Since you didn't create those folder, visually you won't be able to see the difference.由于您没有创建这些文件夹,因此在视觉上您将无法看到差异。

If you have an ultimate edition of intelliJ IDE, you can configure tomcat plugin to run the WAR on pre-installed tomcat server (or use other alternatives for running WARs).如果您有 IntelliJ IDE 的终极版,您可以配置 tomcat 插件以在预安装的 tomcat 服务器上运行 WAR(或使用其他替代方案来运行 WAR)。

In order to learn the impact of packaging, you can run mvn package from the command line and examine the created artifact in the target folder为了了解打包的影响,您可以从命令行运行mvn package并检查target文件夹中创建的工件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM