接口上可以使用@ApplicationPath 注解吗?
Can @ApplicationPath annotation be used on interface?
根据JAXRS规范,@ApplicationPath可以用在接口上吗?
import javax.ws.rs.ApplicationPath;
@ApplicationPath("/")
public interface TestRes {
}
编译器对此没有问题。但这是好方法吗?
你的 class 必须扩展 Application
所以它不能在接口上使用。
ApplicationPath 清晰的文档说它只适用于 subclass
of javax.ws.rs.core.Application
所以如果你在接口上应用它不会工作,所以当你部署时你可能会得到此错误消息 The ResourceConfig instance does not contain any root resource classes."
Identifies the application path that serves as the base URI for all resource URIs provided by Path.May only be applied to a subclass of Application.
The @ApplicationPath annotation is used to define the URL mapping for the application. The path specified by @ApplicationPath is the base URI for all resource URIs specified by @Path annotations in the resource class. You may only apply @ApplicationPath to a subclass of javax.ws.rs.core.Application.
根据JAXRS规范,@ApplicationPath可以用在接口上吗?
import javax.ws.rs.ApplicationPath;
@ApplicationPath("/")
public interface TestRes {
}
编译器对此没有问题。但这是好方法吗?
你的 class 必须扩展 Application
所以它不能在接口上使用。
ApplicationPath 清晰的文档说它只适用于 subclass
of javax.ws.rs.core.Application
所以如果你在接口上应用它不会工作,所以当你部署时你可能会得到此错误消息 The ResourceConfig instance does not contain any root resource classes."
Identifies the application path that serves as the base URI for all resource URIs provided by Path.May only be applied to a subclass of Application.
The @ApplicationPath annotation is used to define the URL mapping for the application. The path specified by @ApplicationPath is the base URI for all resource URIs specified by @Path annotations in the resource class. You may only apply @ApplicationPath to a subclass of javax.ws.rs.core.Application.