Eclipse中导入maven项目,并转为web加载进tomcat

来源:互联网 发布:淘宝如何免费推广 编辑:程序博客网 时间:2024/06/05 03:09
新入职一个公司,需要将代码从SVN上拉下来,或者更换了一个新的工作空间,需要重新启动项目。具体过程可参考以下步骤:

第1步:eclipse中配置maven。Window --> Preferences --> Maven --> Installations --> Add添加maven,


然后设置User Settings,设置Blobal Settings、User Settings、Local Repository,Apply --> OK。



第2步:导入项目,将从svn或其他管理工具上检出的代码导入。

File --> Import --> Maven --> Existing Maven Projects --> Next --> (选择本地项目)。



第3步:将导入的项目转为web项目(以APPSERVER项目为例,其web模块为webserver)。

webserver --> Properties --> Project Facets --> Convert to facetes form... --> Dynamic Web Module 

--> Further configuration available... 

(选择性,Content directory改为:src/main/webapp,取消下面的Generat web.xml...)


第4步:添加tomcat 服务。

Servers 下点击超链接,按步骤往下即可。


第5步:将上述转换后的web项目添加进tomcat服务器。


第6步:启动tomcat服务,由于eclipse不会自动将maven的各模块装载进web模块,因此启动会报错,例如:
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener...
做如下处理:webserver --> Properties --> Deployment Assembly --> Add Java Build Path Entries --> Maven Dependencies --> Finish;

在返回页面:Project --> 选中其他模块添加即可


第7步:重新启动tomcat,启动成功。

选择性配置Ignored Resources