restful service interface with jersey

前端 未结 5 998
日久生厌
日久生厌 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:15

    If you want to use interfaces with JAX-RS annotation you can no longer scan a package with the web.xml

    jersey.config.server.provider.packages
    XXX
    

    You need to manually bind your interface with your resource implementation

    bind(YourResource.class).to(YourResourceImpl.class);
    

    Reason for this :

    We decided for performance reasons that during scanning the interfaces will be ignored. Also we fixed that Jersey will not try to instantiate interfaces.

    https://java.net/jira/browse/JERSEY-1004

提交回复
热议问题