java 警告:(子)资源方法包含空路径注释
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33513654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WARNING: The (sub)resource method contains empty path annotation
提问by brisk
I have configured rest path like "/v1/" and the endpoint configured in servlet like '/test/'.
我已经配置了像“/v1/”这样的休息路径和像“/test/”这样的servlet中配置的端点。
Now I removed the "/v1" from the java class "Test".
现在我从 Java 类“Test”中删除了“/v1”。
org.glassfish.jersey.internal.Errors logErrors
WARNING: The following warnings have been detected: WARNING: The (sub)resource method test in com.abc.services.Test contains empty path annotation.
I got the above warning after make this change. How to handle this warning?
进行此更改后,我收到了上述警告。如何处理这个警告?
And I want this "/v1" removing changes for across 10 rest paths. So anyone help me to run without warnings?
我希望这个“/v1”删除跨 10 个休息路径的更改。所以有人帮我在没有警告的情况下跑步吗?
回答by Paul Samsotha
The warning means you have a resource method annotated with @Path("/")
or @Path("")
. For instance
警告意味着您有一个用@Path("/")
或注释的资源方法@Path("")
。例如
@Path("test")
public class Test {
@GET
@Path("/")
public String test(){}
}
Not sure why Jersey would give a warning, maybe just to make sure that's what you really want. The reason is that a resource method with @Path("/")
is redundant, as it's already implied if you were just to do
不知道为什么泽西岛会发出警告,也许只是为了确保这是你真正想要的。原因是资源方法 with@Path("/")
是多余的,因为它已经暗示如果你只是做
@Path("test")
public class Test {
@GET
public String test(){}
}
without the @Path("/")
. It works the same. So if you have these, remove them, and it should take away the warnings.
没有@Path("/")
. 它的工作原理相同。所以如果你有这些,删除它们,它应该消除警告。