中加入:org.mortbay.jetty 2)生成自己的 maven 项目: 运行-->cmd进入要建立项目的目录. E:\\workspaces>mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=kevinyu -DartifactId=KevinMavenProject
项目已经建好;(一般不使用mvn命令创建项目,一般则使用eclipse 创建项目)
3)eclipse配置:
eclipse -> help -> software updates -> Find and Installs -> search for new features install -> new remote site
安装 Eclipse Maven2 插件 :http://download.eclipse.org/technology/m2e/releases 安装 JETTY 插件 : http://www.webtide.com/eclipse
安装 JETTY-RUN 插件 :http://run-jetty-run.googlecode.com/svn/trunk/updatesite 4)导入项目 运行-->cmd
进入刚才新建项目的目录. e:\\project>mvn eclipse:eclipse
它会自动将项目建成可导入eclipse的项目;
在eclipse中import该项目即可;(配合2使用) 5) 在eclipse中配置maven
Window->Preference->输入maven ->installations
Global setting 中输入E:\\maven\\apache-maven-3.0.4\\conf\\settings.xml userSetting 中user setting 输入C:\\Users\\MUHE\\.m2\\settings.xml (注意 eclipse 的jre 要使用JDK而不是单纯的jre) 6)在eclipse中创建web 项目
New->Project->Maven->maven Project
创建项目完成:其中webapp 相当于一般项目中的webapp
4、通过eclipse运行mvn命令调用 jetty服务器 a、首先需要build项目 项目-》右键-》Run As-》Maven Build--》查看console 输出success b、运行项目 项目-》右键-》Run As-》Run Configuration-》Maven Build右击-》New
最终出来一下结果:
则成功!
访问http://localhost:8080/ 返回结果: