【发布时间】:2016-08-12 22:56:55
【问题描述】:
作为 servicemix/karaf 的新手,我正在尝试创建一个非常简单的程序来接受并返回 REST 请求。我的课程是:
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 中双击服务器并在“端口”部分中设置一个值来指定它将侦听传入请求的端口。如何在 Servicemix 中设置端口,甚至找出它当前正在侦听的端口?我从 Servicemix 中的命令行成功地启动了捆绑包。我的应用程序似乎没有在 80(Apache)、8080(无)或 8181(Servicemix 控制台)上监听
【问题讨论】:
-
如何打包和部署应用程序。我猜你有不止这一门课
标签: osgi port apache-karaf spring-restcontroller apache-servicemix