![](https://img-blog.csdnimg.cn/f0d15dfa21d24dc0a4b7475c382a9706.png)
在学习过程中经常遇到 eclipse 开发的项目,但是由于和 idea 配置有差异不能直接运行,需要做一些修改
1.选择从已有文件导入
![image-20220602092840882](https://img-blog.csdnimg.cn/img_convert/70abb243c1b1e605b078c53132205be1.png)
使用 idea 导入文件,注意这里是导入不是直接打开
import project 与 open 的区别:
import project:如果项目不是用 idea 开发的,用 import 打开。因为这个情况下,这个项目不是 idea 模型,使用 import 可以避免许多不必要的麻烦。
open:如果项目之前就是 idea 开发的,直接用 open 即可
选择文件目录
![image-20220602093008180](https://img-blog.csdnimg.cn/img_convert/3b2eed0ed1c54760acfec4b5583647e0.png)
导入项目选择 eclipse
![image-20220602093035070](https://img-blog.csdnimg.cn/img_convert/744c30447c33edc2ba26e400dc74415e.png)
如果项目是 maven 的话直接 next 就可以直接导入 idea 了,很简单,eclipse 需要以下配置
如果需要修改 jdk 可以在这里修改,不需要的话则一路 next
![image-20220602093153232](https://img-blog.csdnimg.cn/img_convert/2c912257c388c78a36d323bbe2e1fb81.png)
导入完成
![image-20220602093315942](https://img-blog.csdnimg.cn/img_convert/8b239d8c89c18260f060189e50c6dd9c.png)
2.配置依赖
2.1 File - ProjectStructure
![image-20220602093342989](https://img-blog.csdnimg.cn/img_convert/ac03856a33c7117ab612a34af043f5b2.png)
删除不必要的 eclipse 依赖,爆红的依次选中点击减号即可
![image-20220602093445022](https://img-blog.csdnimg.cn/img_convert/749244b75e74700e55dcfe439757d973.png)
我这里 sdk 爆红,在 ModuleSDK 中选择合适的即可
![image-20220602093554821](https://img-blog.csdnimg.cn/img_convert/6dc36e37d0499b9df93fcd28e163dbea.png)
然后添加项目 lib 依赖,按序号步骤,选择 jars or directories
![image-20220602093815256](https://img-blog.csdnimg.cn/img_convert/afe3ca5d50dca09a0ca70300844a2718.png)
选择项目的 lib 目录
![image-20220602093901660](https://img-blog.csdnimg.cn/img_convert/004cd4570063ae2db17a7e439f74c528.png)
2.2 项目为 web 项目的话,还需要手动定位 web.xml
同样的窗口,在左侧栏选择 Facets - Web,点击加号选择 web
![image-20220602094052613](https://img-blog.csdnimg.cn/img_convert/662a8e2f8fef60a95ee33d4f25002172.png)
选中 1 标签处,点击 2 标签处笔的标志,修改 xml 文件目录
![image-20220602094123477](https://img-blog.csdnimg.cn/img_convert/4d9083853d44e3a3ac98588f58f6af9e.png)
因为我演示的项目 web 目录为 webcontent,所以这里可以修改
![image-20220602100517556](https://img-blog.csdnimg.cn/img_convert/b5fbf77dd2bd2b700a19ab4099fb614e.png)
并且点击下面的 create Artifacts,然后点击 fix
![image-20220602100626349](https://img-blog.csdnimg.cn/img_convert/3da9bd67c6f751bc6b054e6fd40bc047.png)
选择 add lib to artifacts,点击 apply - ok,回到项目目录发现项目目录标签多了一个蓝点
![image-20220602100941884](https://img-blog.csdnimg.cn/img_convert/cb7e1c587b4f6eca71dda4ebf3949c6b.png)
3.配置tomcat
点击右上角 add configuration
![image-20220602101013845](https://img-blog.csdnimg.cn/img_convert/094502267752c6a56fd6351ec50403f6.png)
点击左上角加号,选择 tomcat local
![image-20220602101044806](https://img-blog.csdnimg.cn/img_convert/9b9e00597aef93a48df668262546bc9c.png)
配置 tomcat 目录
![image-20220602101122801](https://img-blog.csdnimg.cn/img_convert/6b7b354378ff44727e8984ad26db8d92.png)
如果有错误提示点击 fix
![image-20220602101155094](https://img-blog.csdnimg.cn/img_convert/c6ce937bcecf193f8a0b24c5d578fc9c.png)
![image-20220602101225773](https://img-blog.csdnimg.cn/img_convert/6faf0f87e5d602af803681a23f3a7d5d.png)
配置成功后点击 apply ok
![image-20220602101255283](https://img-blog.csdnimg.cn/img_convert/e423c0fa9e72baaa71dd8847a5155ab8.png)
右上角此状态可以判断为配置成功,如果修改 tomcat 启动端口的话可以点击进入刚才的配置目录
![image-20220602101344113](https://img-blog.csdnimg.cn/img_convert/e51317d3077a2bf5d7430a186cfaf24b.png)
点击 绿色 三角即可以启动项目,如果没有错误的话 idea 会自动打开浏览器打开项目
![](https://img-blog.csdnimg.cn/img_convert/d717a424deb896a4ca97a7f1f83da1f8.png)