jersey创建Restful Web Services

首次使用Jersey,记录一下。


1.通过Maven Archetype创建一个新的工程

方法一:使用模板创建

(1)选择合适的模板:
<span style="font-family:Microsoft YaHei;font-size:14px;">mvn archetype:generate -DarchetypeCatalog=http://download.java.net/maven/2</span>

(2)选择模板:
<span style="font-family:Microsoft YaHei;font-size:14px;">[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)  
Choose archetype:  
1: http://download.java.net/maven/2 -> com.sun.jersey.archetypes:jersey-quickstart-grizzly (Archetype for creating a RESTful web application with Jersey and Grizzly)  
2: http://download.java.net/maven/2 -> com.sun.jersey.archetypes:jersey-quickstart-grizzly2 (Archetype for creating a RESTful web application with Jersey and Grizzly 2.x)  
3: http://download.java.net/maven/2 -> com.sun.jersey.archetypes:jersey-quickstart-webapp (Archetype for creating a Jersey based RESTful web application with WAR packaging)  
4: http://download.java.net/maven/2 -> com.sun.jersey.archetypes:jersey-quickstart-ejb (Archetype for creating a Jersey based RESTful EJB application with WAR packaging)  
5: http://download.java.net/maven/2 -> com.sun.faces:simple-jsf (Archetype for creating a simple JSF project)  
6: http://download.java.net/maven/2 -> com.sun.faces.regression:i_jsf_XXXX-archetype (Archetype for mojarra JSF regression tests) </span>

(3)填入信息:

<span style="font-family:Microsoft YaHei;font-size:14px;">Define value for property 'groupId': : com.nercel
Define value for property 'artifactId': : services
Define value for property 'version':  1.0-SNAPSHOT: :   
Define value for property 'package':  com.esri: :   
Confirm properties configuration:  
groupId: com.nercel  
artifactId: services
version: 1.0-SNAPSHOT  
package: com.nercel
 Y: : y  </span>

上述方法非常方便,但是我操作的时候出现了点小问题,没有解决直接换了方法二,下次用到的时候再试下吧。

方法二:使用命令行方式创建模板

(1)创建自定义模板
<span style="font-family:Microsoft YaHei;font-size:14px;">mvn archetype:generate  -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArtifactId=jersey-quickstart-webapp   -DarchetypeVersion=2.4.1</span>

(2)填入信息
<span style="font-family:Microsoft YaHei;font-size:14px;">Define value for property 'groupId': : com.nercel
Define value for property 'artifactId': : services
Define value for property 'version':  1.0-SNAPSHOT: :   
Define value for property 'package':  com.esri: :   
Confirm properties configuration:  
groupId: com.nercel  
artifactId: services
version: 1.0-SNAPSHOT  
package: com.nercel
 Y: : y  </span>

(3)将maven-resources-plugins加入pom.xml
<span style="font-family:Microsoft YaHei;font-size:14px;"><dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.5</version>
</dependency></span>
(4)更新工程的maven








参考:

1.https://jersey.java.net/download.html

2.http://www.tuicool.com/articles/JvE7vm

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值