Can @ApplicationPath annotation be used on interface?

masterdany88 :

According to JAXRS spec, is @ApplicationPath can be used on interface?

import javax.ws.rs.ApplicationPath;

@ApplicationPath("/")
public interface TestRes {

}

Compiler dont have a problem with that. But is this good approach?

Deadpool :

ApplicationPath Documentation cleary says it is only applicable for subclass of javax.ws.rs.core.Application so if you apply on the interface it will not work, so when you deploy you might end up with this error message 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.

jaxrs

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=328183&siteId=1