servicemix:我的 osgi 包在哪个端口上监听?
servicemix: on which port is my osgi bundle listening?
作为 servicemix/karaf 的新手,我正在尝试创建一个非常简单的程序来接受和 returns REST 请求。我的 class 是:
package (....)
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import (...).model.RSDocument;
import (...).model.RSDocumentResponse;
@RestController
public class DocumentService {
@RequestMapping(value = "/rest/document", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<RSDocumentResponse> printDocument(
@RequestBody RSDocument documentRequest)
{
System.out.println(documentRequest.getContent());
RSDocumentResponse response = new RSDocumentResponse();
response.setSuccess(true);
return new ResponseEntity<>(response, HttpStatus.OK);
}
}
我在 Tomcat 中有类似的工作。在 Tomcat 中,您可以通过双击 eclipse 中的服务器并在 "Ports" 部分中设置一个值来指定监听传入请求的端口。如何在 Servicemix 中设置端口,甚至找出它当前正在侦听的端口?我从 Servicemix 中的命令行成功启动了捆绑包。我的应用程序似乎没有在 80 (Apache)、8080 (None) 或 8181(Servicemix 控制台)
上侦听
首先确保您已部署网络容器。为此,请确保安装了 war 功能。
feature:list | grep war
如果未安装,请通过以下命令安装:
feature:install war
现在,确保您的 jar/war 包含 Web-ContextPath 清单条目告诉网络容器哪个上下文路径寻找。如果您安装了所有其他必需的包并且 运行,包括所有依赖项都已设置,您应该能够导航到您的休息服务:
localhost:8181/myContextPath/rest/document
作为 servicemix/karaf 的新手,我正在尝试创建一个非常简单的程序来接受和 returns REST 请求。我的 class 是:
package (....)
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import (...).model.RSDocument;
import (...).model.RSDocumentResponse;
@RestController
public class DocumentService {
@RequestMapping(value = "/rest/document", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<RSDocumentResponse> printDocument(
@RequestBody RSDocument documentRequest)
{
System.out.println(documentRequest.getContent());
RSDocumentResponse response = new RSDocumentResponse();
response.setSuccess(true);
return new ResponseEntity<>(response, HttpStatus.OK);
}
}
我在 Tomcat 中有类似的工作。在 Tomcat 中,您可以通过双击 eclipse 中的服务器并在 "Ports" 部分中设置一个值来指定监听传入请求的端口。如何在 Servicemix 中设置端口,甚至找出它当前正在侦听的端口?我从 Servicemix 中的命令行成功启动了捆绑包。我的应用程序似乎没有在 80 (Apache)、8080 (None) 或 8181(Servicemix 控制台)
上侦听首先确保您已部署网络容器。为此,请确保安装了 war 功能。
feature:list | grep war
如果未安装,请通过以下命令安装:
feature:install war
现在,确保您的 jar/war 包含 Web-ContextPath 清单条目告诉网络容器哪个上下文路径寻找。如果您安装了所有其他必需的包并且 运行,包括所有依赖项都已设置,您应该能够导航到您的休息服务:
localhost:8181/myContextPath/rest/document