restful service interface with jersey

前端 未结 5 1001
日久生厌
日久生厌 2020-12-11 07:44

Can I create a restful service with interface and implementation class?

If so, will all JAX-RS related imports go into the interface?

I am using jersey2.4 an

5条回答
  •  执念已碎
    2020-12-11 08:13

    Yes you can use the interface to annotate. In our application we have implemented by this way. following quote is taken from Jersy specifications.

    JAX-RS annotations MAY be used on the methods and method parameters of a super-class or an implemented interface. Such annotations are inherited by a corresponding sub-class or implementation class method provided that method and its parameters do not have any JAX-RS annotations of its own. Annotations on a super-class take precedence over those on an implemented interface. If a subclass or implementation method has any JAX-RS annotations then all of the annotations on the super class or interface method are ignored

    I think in your case the error because of you may have missed mapping please check. api /api/*

提交回复
热议问题