##开发工具
下载Eclipse ,maven
##maven配置
下载了lastest version,文件名:apache-maven-3.2.1-bin.tar.gz
将解压在当前目录下。
将解压后的apache-maven-3.2.1文件夹移到/usr/local/maven目录(不存在则新建)下,并重命名为maven3.2.1
即:
/usr/local/maven/maven3.2.1
参考maven官网的安装指导
http://maven.apache.org/download.cgi#Installation,
并结合其他网友贡献的资料,做以下工作:
终端中执行 vi ~/.bash_profile
然后输入
M3_HOME=/usr/local/maven/maven3.2.1
PATH=$M3_HOME/bin:$PATH
按下esc
键输入:wq
然后在终端输入
如果能输出类似
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-12T04:58:10+08:00)
Maven home: /Users/zhangruquan/need/apache-maven-3.2.3
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: zh_CN, platform encoding: EUC_CN
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"
就说明安装成功了
##jersey的RESTful服务器的搭建
Eclipse->New->Project->Maven Project->Next ->Add Archetype->Archetype Group Id:org.glassfish.jersey.archetypes ,Archetype Artifact Id:jersey-quickstart-webapp ,Archetype Version:2.21 ->ok->选择刚才创建的Archetype->next->Group Id:csdn ,Artifact Id:testPush,Version 0.0.1->Finish
在pom.xml文件中插入
<dependency>
<groupId>com.github.fernandospr</groupId>
<artifactId>javapns-jdk16</artifactId>
<version>2.3</version>
</dependency>
另外将MyResource.java 替换为以下内容
然后Run As ->Maven install
然后将testpush.war部署到服务器
##测试
测试时候postman 测试
http://localhost:8080/testpush/webapi/myresource/push?address=381883f2f7192337bbee8abf8b8f7f12eee284b94fa389470049997670831ef1&badgeNum=10&message=你好
这里一定要注意有webapi