源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

maven搭建java ee项目图文教程

  • 时间:2022-08-22 02:20 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:maven搭建java ee项目图文教程
[b]一、开发环境[/b] jdk1.7  tomcat7 eclipse-jee-luna-R-win32 maven2.2.1 [b]二、搭建步骤[/b] 1、点击File->New->Other,选择maven project [img]http://files.jb51.net/file_images/article/201604/201604221052353.jpg[/img] 2、选择maven project,点击Next,,而后再点击next,进入如下界面 [img]http://files.jb51.net/file_images/article/201604/201604221052354.jpg[/img] 如图选择最后一个,点击next 3、看到以下界面 [img]http://files.jb51.net/file_images/article/201604/201604221052355.jpg[/img] 输入Group Id跟Artifact Id,点击finish完成基本创建 4、创建好的项目结构如图所示(Java视图) [img]http://files.jb51.net/file_images/article/201604/201604221052366.jpg[/img] 如果是Java EE视图,看到的项目结构不是这个样子的,可以如下更换为java 视图 [img]http://files.jb51.net/file_images/article/201604/201604221052367.jpg[/img] 5、右击项目->Build Path->Configure Build Path..进入如下界面 [img]http://files.jb51.net/file_images/article/201604/201604221052378.jpg[/img] 有鼠标点击选中右侧表示红叉的,点击remove删除,点击ok保存 6、添加source folder,创建标准的maven web项目结构 右击项目->New->Source Folder->填入folder name,如图所示 [img]http://files.jb51.net/file_images/article/201604/201604221052379.jpg[/img] 依次添加src/main/java  src/test/java  src/test/resources(src/main/resources已经存在) 7、新的项目结构如图所示 [img]http://files.jb51.net/file_images/article/201604/2016042210523710.jpg[/img] 8、配置输出路径 右击项目->Build Path->Configure Build Path..进入如下界面 [img]http://files.jb51.net/file_images/article/201604/2016042210523811.jpg[/img] 鼠标分别选中src/test/java,src/test/resources,点击Edit,更改输出目录为:testDemo02/target/test-class(testDemo为我的项目名) [img]http://files.jb51.net/file_images/article/201604/2016042210523812.jpg[/img] 如果Browse有该目录存在,则选择;否则手动输入testDemo02/target/test-class即可 8、更新相关版本 右击项目->Properties->Project Facets,将jdk 更改为本地安装的版本,我的是1.7;Dynamic Web Modul在此处更改不了 [img]http://files.jb51.net/file_images/article/201604/2016042210523813.jpg[/img] 找到项目位置,更改.setting文件下的org.eclipse.wst.common.project.facet.core.xml文件,更改这行配置<installed facet="jst.web" version="2.3"/>,将version改为3.0 在eclipse中更新项目,再次右击项目->Properties->Project Facets,会看到Dynamic Web Modul已经改为3.0 9、设置部署程序集合 右击项目->properties->Deployment Assembly。 删除test的两项,因为test是测试用的,不需要部署; 添加maven的依赖;Add->Java Build Path Entires->Maven Dependencies->Finish 设置完成的界面如下 [img]http://files.jb51.net/file_images/article/201604/2016042210523814.jpg[/img] 10、在pom.xml添加相关依赖,更新maven项目 11、在eclipse 添加Tomcat server,将项目添加到该server中,启动tomcat,而后访问项目http://localhost:8080/testDemo02/ 就可以看到熟悉的界面了。 以上就是maven搭建java ee项目的详细步骤,希望对大家的学习有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部