第一步,先到idea如下图界面,并且按图示点击:
第二步,在弹出的页面选择你所要导入的项目:
第三步,如下图所示操作:
第四步,一直点击next直到如下界面,确认jdk,然后再点击finish:
第五步,到这里项目已经初步导入idea了,接下来直接给项目添加tomcat来运行,如下图所示:

pic-1596529981301.png
点击local之后,问题就来了,如下图:
提示:No artifacts configured,但是右边有个小按钮fix,点击之后,跳转到下图:
选择创建一个web Application:exploded,但是这样直接创建的是一个空的,无用的,如下图:

pic-1596529981305.png
可以看见,到这里,tomcat已经不再报那个错误了。我们可以先试着把项目运行一遍试试,结果如下图:

服务器确实到这一步已经成功启动了,但是首页并不是我项目里面所配置的,所以说,刚刚给tomcat添加了一个空的,无用的web Application:exploded,到这里是最关键的了。
第六步,已经成功给项目添加了tomcat运行,但是tomcat运行的Artifacts包是一个空的包,并没有内容在里面。接下来给tomcat添加一个有用的Artifacts包。

到如下页面:

从第一个Project目录开始看

第一个目录,暂时没有问题,接下来看Modules目录,如下图:

项目名竟然标红了,猜想是有问题的,如下图所示进行修改:


在上图中我所标注的1,那里的路径应该是项目的web.xml路径,可是这个路径却是错误了,对其进行修改(修改成自己项目里所对应的web.xml路径)我所标注的2那里的路径应该是对应的web Resource Directory目录,因为是eclipse项目所以应该对应的目录是WebContent目录。在我所标注的3那里,点击右侧的fix小按钮,选择Create Artifacts按钮,这时候会在第五个目录Artifacts生成一个Web Application:exploded。修改结果如下:

回到第二个目录(Modules),点击Apply按钮,可以看见项目名Portallib2.0并没有标红了。

接下来看第三个目录:

是项目所需要的一些jar包。第四个目录:

在第二个目录(modules)已经对两个路径进行了修改,这里不做任何修改。对五个目录里的内容完成了修改。点击OK,去tomcat那里重新添加Artifacts。

先删除,后添加:

第七步:重新运行项目测试


测试成功!!!