如何在Intellij IDEA上导入现有的Maven + Spring MVC + Tomcat项目?

如何在Intellij IDEA上导入现有的Maven + Spring MVC + Tomcat项目?

问题描述:

我是IntelliJ IDEA的新手。我从git仓库导入了项目。现在我尝试在Tomcat 8.5上运行它但没有成功。我知道我需要配置maven命令将我的项目打包到war文件中,但我不知道在哪里做。

I'm new to IntelliJ IDEA. I've imported project from git repository. Now I try to run it on Tomcat 8.5 with no success. I understand that I need to configure maven command to package my project in war file, but I do not know where to do it.

在Intellij中导入你的项目。

从现有的源 - >转到file-> new-> project,然后选择 pom.xml 。然后按照IntelliJ给出的说明检查maven的框,自动下载项目的依赖项。

Go to file->new->project from existing source-> then select the pom.xml from your project location on your disk. then follow the instruction given by IntelliJ.Check the box for maven to automatically download dependency for your project.

从您的代码创建战争

运行 mvn从 pom.xml 所在的目录中清理包。它将在同一文件夹的目标文件夹中创建 war 文件,其中 pom.xml 存在。

Run mvn clean package from the directory where pom.xml is present. it will create war file in the target folder of same folder, where pom.xml is present.

根据想法创建war文件

点击最右边的图标 maven项目在想法中你会看到不同的maven生命周期,点击 package 来创建项目的war文件。再次在项目的目标文件夹中可以使用相同的war文件。

Click on the right most icon of maven project in idea and there you will see different maven lifecycle, click on package to create war file of your project. again same war file will be available inside the target folder of your project.

按照下面的图像更清晰: -

follow below images for more clarity:-