0

我正在使用 Maven/Jetty 运行我的应用程序并向其发送发布请求。

$mvn jetty:run
$curl -H "Content-Type:application/json" -XPOST 'http://localhost:8080/hi' -d '{"url":"http://www.subway.com", "operator":1}

这是我的课的一个例子。它使用 RestEasy 连接所有内容,以便 curl 到 localhost:8080/hi 导致调用 handlePost():

@Path("/hi")
public class Hi {
    @POST
    @Consumes("application/json")
    @Produces("text/plain")
    public Response handlePost() {
        return Response.status(HttpStatus.SC_OK).entity("hey!").build();
    }
}

注意这将输出

"hey!" 

我希望能够有效地调试我的代码,并且想知道是否有办法

  1. 使用 IDE 使断点工作和调试(使用 IntelliJ)
  2. 向终端输出一些简单的东西

对于#1,我不确定从哪里开始。对于#2,我尝试了

System.out.println("hello!");

但它永远不会被输出,大概是因为我没有从终端运行我的程序?

4

1 回答 1

0

Instead of using mvn jetty:run to launch your Web application from the command line, launch your application from your IDE. It should attach a debugger and allow you to use your standard tools. The client you use to talk to the application doesn't matter, so curl will work just fine.

于 2013-07-31T22:02:45.007 回答