I don\'t know if the title is confusing, but let\'s say I have this interface:
@Produces(MediaType.APPLICATION_JSON)
@Path(\"/user\")
public interface UserSe
I had a similar issue working with interface automatically generated using the OpenAPI generator. The problem here was that I couldn't easily remove the @Path annotation from the interface and additionally adding it to the class caused ambiguity issues.
Problems with @Path-annotated interfaces however only occurs for resources that are automatically discovered on registered packages. For registered packages, all classes (and unfortunately interfaces as well) that are annotated with @Path will be instantiated.
To prevent that, you can just register your resources manually with your ResourceConfig as in the following example:
new ResourceConfig()
.registerClasses(UserServiceImpl.class);
Just make sure, your interfaces are not in a package that are registered with your ResourceConfig. Using this approach, you can use the implementation from your example and also the @Path annotation added to the interface will be interpreted correctly.
Disclaimer: There probably should not be any @Path path annotation on the interface in the first place, but unfortunately this is what the OpenAPI generator creates. If you find yourself in a similar situation, I hope this helps. Otherwise, you should refer to the accepted answer.