Spring Restfull Jax-RS annotation support
Just put your JAX-RS (I'm using Jersey 2) annotations on a class, annotate that class with @Component to make it a Spring bean, and you have full JAX-RS support with Spring dependency injection.
So Spring hasn't reinvented the wheel by implementing JAX-RS itself, but integrates very easily with Jersey for example.
Here's a simple Spring boot example:
http://spring.io/blog/2014/11/23/bootiful-java-ee-support-in-spring-boot-1-2
If you want to develop the webservices using only Spring framework then Spring provides Spring MVC. Spring MVC has its own set of annotations. For e.g. "@RequestMapping". Spring MVC doesn't even adhere to the JAX-RS principles.
There are various opensource frameworks (like Jersey) which supports "JAX-RS" and can be integrated with Spring.
However, just in case you want to compare the Spring MVC with Jersey then below is the comparison. I personally support Jersey over SPring MVC as Spring MVC is not originally meant for webservices but for UI application.
- Same relative paths in multiple @Controllers not supported
- @ExceptionHandler is controller-centric
- Standard content negotiation can’t respond with a fixed response type (SPR-6937)
- JSR 303 bean validation not applied in @Controllers (SPR-6928, scheduled for 3.1)
- Formatting responses (i.e. Date) not working using Spring formatter annotations
- You cannot return a bean from an exception handler and expect it to be automatically serialized to xml or json based on the incoming accept header.
HTH...
No, you cannot use javax.ws.*
annotations in spring. You can use something like resteasy
with spring. It is rather easy. If you need I can provide with an example. (Jersey and CXF has good JAX-RS implementations too.)
AFAIK Springsource has no idea to provide an implementation to JAX-RS. So if you want to use the features described in JAX-RS you will not get it directly from spring. But you can develop a rest web service using spring. That's a different story. A question was found on SO on that.
Update
Depending on PaulNUK's answer below, I need to clarify my answer. End of the day rest is a specification, and someone needs to implement it in first place.
Question clearly asks, whether we can replace the annotations, you cant do it, unless you add an external dependency like Jersey to your classpath. That case implementation is provided by Jersey.
Therefore you would never be able to use spring implemented JAX-RS annotation ever.