2

Here, several questions have been asked by many developers about difference between Spring-Rest and JAX-RS. And, I have also learned that Spring is not following any specification and Spring framework has their own implementation then

  • Why Spring allows all that Annotations which are supported/used by JAX-RS by default?
Jimesh Shah
  • 113
  • 10
  • [Please read this comment exchange](https://stackoverflow.com/q/60725696/2587435) – Paul Samsotha Apr 19 '20 at 04:44
  • @PaulSamsotha Thanks but I could not clearly understand what Nate was trying to say. It would be better for me If you explain me with an example or briefly. – Jimesh Shah Apr 19 '20 at 12:59
  • Spring does not support JAX-RS annotations. That's that point. If there's any situation where you think they do, then you are mistaken. Period. – Paul Samsotha Apr 19 '20 at 16:36
  • What will happen if I will add those annotations in my Spring program? Exception/Error will be thrown? – Jimesh Shah Apr 20 '20 at 05:04
  • Nothing will happen. Annotations are just metadata. They are not programs. If Spring does not recognize the metadata, it will ignore it. But if you use a JAX-RS annotation in place of Spring annotation that is meant for the same thing, then you will not get the expected Spring behavior. So basically, if you are using Spring MVC, remove any JAX-RS dependencies so you don't mistakenly use them. – Paul Samsotha Apr 22 '20 at 06:39
  • Please add your comments in the answer box. I will accept. – Jimesh Shah Apr 22 '20 at 06:54

1 Answers1

3

Spring does not support JAX-RS annotations. If there is a situation where you think they do, then you are mistaken or it's just a coincidence. Period. If you will add any JAX-RS annotations in my Spring MVC program, nothing will happen. Annotations are just metadata. They are not programs. If Spring does not recognize the metadata, it will ignore it. But if you use a JAX-RS annotation in place of a Spring annotation that is used for the same purpose, respective of their framework, then you will not get the expected Spring behavior. So basically, if you are using Spring MVC, remove any JAX-RS dependencies so you don't mistakenly use them.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720