如何在eclipse jee中创建Maven project并且转换为Dynamic web project
2015-07-14 16:14
721 查看
注意:该文档只针对以下eclipse版本,如图
![](http://static.zuidaima.com/images/1/201312/20131221121801267_650x325.jpg)
为了方便,我将我本地的压缩包放在了微云网盘中,大家可以直接下载,jee,subversion,m2eclipse都集成好了,下载地址
链接:http://pan.baidu.com/s/1i3pDNd7
一.创建maven工程
在eclipse的菜单栏选择File->New->Other->Maven->Maven Project
下一步后选择Create a simple project(skip archetype selection),如图
![](http://static.zuidaima.com/images/maven/create_maven_project_1_650x325.jpg)
下一步后输入Group Id,Archive Id,Packaging后点击Finish,如图
![](http://static.zuidaima.com/images/maven/create_maven_project_2_650x325.jpg)
创建成功后的文件目录,如图
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/24/5f424c8f198697ddde641ce4d656d316.jpg)
二.转换为java的Dynamic Web Project
右键点击Project的名称,选择Properties
选择Project Facets->Convert to Faceted from...,如图
![](http://static.zuidaima.com/images/maven/translate_maven_project_to_jee_dynamic_project_1_650x325.jpg)
选择Dynamic Web Module,Version为2.5(3.0版本我没测试过是否可行),选择Java,Version为1.6,并点击Further configuration available...如图
![](http://static.zuidaima.com/images/maven/translate_maven_project_to_jee_dynamic_project_2_650x325.jpg)
修改Content directory为/src/main/webapp/,点击OK,如图
![](http://static.zuidaima.com/images/maven/translate_maven_project_to_jee_dynamic_project_3_650x325.jpg)
最后点击Properties for showcase的OK完成转换,最后的目录结构,如图
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/24/47ed0fc01bca7855afb0123e3e36d10d.jpg)
三.修改Java Build Path
右键点击Project的名称,选择Properties
选择Java Build Path,将JRE 1.5版本Remove掉,然后点击Add Library,如图
![](http://static.zuidaima.com/images/maven/edit_configuration_1_650x325.jpg)
选择JRE System Library,点击Next,如图
![](http://static.zuidaima.com/images/maven/edit_configuration_2_650x325.jpg)
选择你设置的jdk6版本,点击Finish,如图
![](http://static.zuidaima.com/images/maven/edit_configuration_3_650x325.jpg)
最后点击OK,完成设置,如图
![](http://static.zuidaima.com/images/maven/edit_configuration_4_650x325.jpg)
四.修改Java Compile
右键点击Project的名称,选择Properties
选择Java Compiler,并选择Compiler compliance level为1.6,如图
![](http://static.zuidaima.com/images/maven/edit_java_compiler_650x325.jpg)
五.修改Deployment Assembly
右键点击Project的名称,选择Properties
选择Deployment Assembly,并点击Add,如图
![](http://static.zuidaima.com/images/maven/edit_Deployment_Assembly_1_650x325.jpg)
选择Java Build Path Entries,点击Next,如图
![](http://static.zuidaima.com/images/maven/edit_Deployment_Assembly_2_650x325.jpg)
选择Maven Dependencies,点击Finish,如图
![](http://static.zuidaima.com/images/maven/edit_Deployment_Assembly_3_650x325.jpg)
最好点击OK,完成设置,如图
![](http://static.zuidaima.com/images/maven/edit_Deployment_Assembly_4_650x325.jpg)
六.设置Server Apache Tomcat
菜单栏选择Window->Show View->Servers
点击new server wizard,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_1_650x325.jpg)
选择Tomcat v6.0 Server,点击Next,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_2_650x325.jpg)
选择Browse,选择正确的Apache Tomcat的安装目录,然后点击Next,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_3_650x325.jpg)
选择要部署的项目如showcase,然后点击Add,点击Finish,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_4_650x325.jpg)
xxx
注意:
在Add and Remove的时候提示这个:Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modules
![](http://static.zuidaima.com/images/1/201401/20140104112823168_650x325.jpg)
![](http://static.zuidaima.com/images/1/201401/20140104113302512_650x325.jpg)
![](http://static.zuidaima.com/images/1/201401/20140104113352446_650x325.jpg)
完成设置后的项目如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_5_650x325.jpg)
在Servers View上双击Tomat v6.0 Server at localhost[Stopped Republish],如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_6_650x325.jpg)
修改项目的部署目录为Tomcat installtion目录,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_7_650x325.jpg)
修改项目的访问路径,即去掉比如http://localhost/showcase/目录中的showcase,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_8_650x325.jpg)
关掉Auto reloading enabled,这样不用每次修改文件就自动部署,如图
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/24/af3cf932aeea03baaa9fa195135e14f6.jpg)
右键点击Tocmat v6.0 Server at localhost[Stopped Republish],点击Clean即可完成web project的部署,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_10_650x325.jpg)
最后在Tomcat的目录部署成功,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_11_650x325.jpg)
七.在Apache Tomcat中运行项目
选择Debug可以调试该项目,选择Run可以运行该项目,如图
![](http://www.zuidaima.com/images/maven/run_at_tomcat_650x325.jpg)
![](http://static.zuidaima.com/images/1/201312/20131221121801267_650x325.jpg)
为了方便,我将我本地的压缩包放在了微云网盘中,大家可以直接下载,jee,subversion,m2eclipse都集成好了,下载地址
链接:http://pan.baidu.com/s/1i3pDNd7
一.创建maven工程
在eclipse的菜单栏选择File->New->Other->Maven->Maven Project
下一步后选择Create a simple project(skip archetype selection),如图
![](http://static.zuidaima.com/images/maven/create_maven_project_1_650x325.jpg)
下一步后输入Group Id,Archive Id,Packaging后点击Finish,如图
![](http://static.zuidaima.com/images/maven/create_maven_project_2_650x325.jpg)
创建成功后的文件目录,如图
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/24/5f424c8f198697ddde641ce4d656d316.jpg)
二.转换为java的Dynamic Web Project
右键点击Project的名称,选择Properties
选择Project Facets->Convert to Faceted from...,如图
![](http://static.zuidaima.com/images/maven/translate_maven_project_to_jee_dynamic_project_1_650x325.jpg)
选择Dynamic Web Module,Version为2.5(3.0版本我没测试过是否可行),选择Java,Version为1.6,并点击Further configuration available...如图
![](http://static.zuidaima.com/images/maven/translate_maven_project_to_jee_dynamic_project_2_650x325.jpg)
修改Content directory为/src/main/webapp/,点击OK,如图
![](http://static.zuidaima.com/images/maven/translate_maven_project_to_jee_dynamic_project_3_650x325.jpg)
最后点击Properties for showcase的OK完成转换,最后的目录结构,如图
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/24/47ed0fc01bca7855afb0123e3e36d10d.jpg)
三.修改Java Build Path
右键点击Project的名称,选择Properties
选择Java Build Path,将JRE 1.5版本Remove掉,然后点击Add Library,如图
![](http://static.zuidaima.com/images/maven/edit_configuration_1_650x325.jpg)
选择JRE System Library,点击Next,如图
![](http://static.zuidaima.com/images/maven/edit_configuration_2_650x325.jpg)
选择你设置的jdk6版本,点击Finish,如图
![](http://static.zuidaima.com/images/maven/edit_configuration_3_650x325.jpg)
最后点击OK,完成设置,如图
![](http://static.zuidaima.com/images/maven/edit_configuration_4_650x325.jpg)
四.修改Java Compile
右键点击Project的名称,选择Properties
选择Java Compiler,并选择Compiler compliance level为1.6,如图
![](http://static.zuidaima.com/images/maven/edit_java_compiler_650x325.jpg)
五.修改Deployment Assembly
右键点击Project的名称,选择Properties
选择Deployment Assembly,并点击Add,如图
![](http://static.zuidaima.com/images/maven/edit_Deployment_Assembly_1_650x325.jpg)
选择Java Build Path Entries,点击Next,如图
![](http://static.zuidaima.com/images/maven/edit_Deployment_Assembly_2_650x325.jpg)
选择Maven Dependencies,点击Finish,如图
![](http://static.zuidaima.com/images/maven/edit_Deployment_Assembly_3_650x325.jpg)
最好点击OK,完成设置,如图
![](http://static.zuidaima.com/images/maven/edit_Deployment_Assembly_4_650x325.jpg)
六.设置Server Apache Tomcat
菜单栏选择Window->Show View->Servers
点击new server wizard,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_1_650x325.jpg)
选择Tomcat v6.0 Server,点击Next,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_2_650x325.jpg)
选择Browse,选择正确的Apache Tomcat的安装目录,然后点击Next,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_3_650x325.jpg)
选择要部署的项目如showcase,然后点击Add,点击Finish,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_4_650x325.jpg)
xxx
注意:
在Add and Remove的时候提示这个:Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modules
![](http://static.zuidaima.com/images/1/201401/20140104112823168_650x325.jpg)
![](http://static.zuidaima.com/images/1/201401/20140104113302512_650x325.jpg)
![](http://static.zuidaima.com/images/1/201401/20140104113352446_650x325.jpg)
完成设置后的项目如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_5_650x325.jpg)
在Servers View上双击Tomat v6.0 Server at localhost[Stopped Republish],如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_6_650x325.jpg)
修改项目的部署目录为Tomcat installtion目录,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_7_650x325.jpg)
修改项目的访问路径,即去掉比如http://localhost/showcase/目录中的showcase,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_8_650x325.jpg)
关掉Auto reloading enabled,这样不用每次修改文件就自动部署,如图
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/24/af3cf932aeea03baaa9fa195135e14f6.jpg)
右键点击Tocmat v6.0 Server at localhost[Stopped Republish],点击Clean即可完成web project的部署,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_10_650x325.jpg)
最后在Tomcat的目录部署成功,如图
![](http://static.zuidaima.com/images/maven/set_server_tomcat_11_650x325.jpg)
七.在Apache Tomcat中运行项目
选择Debug可以调试该项目,选择Run可以运行该项目,如图
![](http://www.zuidaima.com/images/maven/run_at_tomcat_650x325.jpg)
相关文章推荐
- 如何在eclipse jee中检出项目并转换为Maven project,最后转换为Dynamic web project
- 整理的一些java中常使用jar包以及说明
- jdk源码阅读-HashMap
- Maven那点事儿(Eclipse版)
- MyEclipse连接不上genymotion的解决方案
- spring3整合quartz2,实现动态添加、修改、暂停、重启定时任务
- eclipse JAVA NDK build path
- Java两种延时——thread和timer
- java.io.FileNotFoundException: savepath\huachuan\photo (拒绝访问。)异常处理
- AnyPoint Studio/Mule ESB failed to create the java virtual machine 解决办法
- 用CXF编写基于spring的web service
- Java中判断字符串是否为数字的五种方法
- JAVA的包package命名规则 要小写
- java垃圾回收与内存分配
- jdk源码阅读-Map
- Spring环境搭建
- Spring中使用quartz执行定时任务的两种方式
- java操作excel的方法
- eclipse编译so库
- Java基础--异常--对多异常的处理