首次使用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>
<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
参考: