我想向您询问有关 jersey api 的 RESTFUL;每当我们在 spring 中进行基于注释的配置(例如其方面)时,我们都可以使用注释或基于 xml 的配置。
@Aspect in class
或
<aop:aspect></aop:aspect> in xml
在具有单独 xml 的 RESTFUL with jersey api
中是否有类似的选项?
@Path("/hello")
public class RestHelloWorld {
@GET
@Produces(MediaType.TEXT_PLAIN)
// method
}
至
这些路径、方法和其他注释的一些xml配置。
最佳答案
嗯,Jersey 是 JAX-RS
的实现,因此首先查看 JAX-RS
规范(可下载 here ),没有提及任何XML配置机制。相反,规范明确指出它是基于 POJO:
The API will provide a set of annotations and associated classes/interfaces that may be used with POJOs in order to expose them as Web resources. The specification will define object lifecycle and scope.
通读 Jersey user guide ,看来 Jersey(正如预期的那样)没有添加自己的 XML 配置机制。
所以,看起来它将一直是注释。总的来说,就JavaEE而言,XML配置机制似乎正在慢慢走上渡渡鸟的道路。
关于java - 使用 xml 配置 Jersey RESTFUL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25345786/