📅  最后修改于: 2020-10-13 08:11:59             🧑  作者: Mango
首先,REST代表代表性状态转移。它是一种基于无状态,可缓存的客户端-服务器协议(大多数情况下为HTTP)开发Web服务的方法。
REST Web服务使用HTTP请求从网络发布,获取和删除数据。
mvn archetype:generate
-DgroupId = com.tuts.abhinav
-DartifactId = rest-service
-DarchetypeArtifactId = maven-archetype-quickstart
-DinteractiveMode = false
org.apache.servicemix.specs
org.apache.servicemix.specs.jsr311-api-1.1.1
1.9.0
provided
org.apache.servicemix
servicemix-http
2013.01
log4j
log4j
1.2.16
install
org.apache.felix
maven-bundle-plugin
2.3.4
true
rest-example-database-post-method
*
fusesource.m2
FuseSource Community Release Repository
http://repo.fusesource.com/nexus/content/repositories/releases
false
true
fusesource.m2
FuseSource Community Release Repository
http://repo.fusesource.com/nexus/content/repositories/releases
false
true
fusesource.ea
FuseSource Community Early Access Release Repository
http://repo.fusesource.com/nexus/content/groups/ea
false
true
在com / tuts /下创建类UserService.java
package com.tuts;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/UserService_1")
public class UserService {
@GET
@Path("/get_data")
@Produces(MediaType.APPLICATION_JSON)
public String getUser() {
String reponse = "This is standard response from REST";
return reponse;
}
}
在/ src / main / resources / OSGI-INF / blueprint blueprint.xml下创建blueprint.xml
install -s mvn:com.tuts.abhinav/rest-service/1.0-SNAPSHOT
开启网址http:// localhost:8181 / cxf
打开URL http:// localhost:8181 / cxf / users12 / UserService_1 / get_data