简体   繁体   中英

Configure jersey RESTFUL using xml

I would like to ask you about RESTFUL with jersey api;whenever we are doing annotaion based configuration in spring for example of its Aspects we can use Annotation or xml based configuration.

@Aspect in class 

or

<aop:aspect></aop:aspect> in xml

Is there any option available like this in RESTFUL with jersey api with seperate xml?

@Path("/hello")
public class RestHelloWorld { 
 @GET
 @Produces(MediaType.TEXT_PLAIN)
 // method
}

to

some xml configuration for these path,method and other annotations.

Well, Jersey is an implementation of JAX-RS , so looking at the JAX-RS specification (downloadable here ) first, there is no mention of any XML configuration mechanism. Instead the specification clearly states that it is POJO-based :

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.

Reading through the Jersey user guide , it seems that Jersey (as expected) does not add on an XML configuration mechanism of its own.

So, it looks like it's going to be annotations all the way. In general, it seems that as far as JavaEE is concerned, XML configuration mechanisms are slowly going the way of the dodo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM