JAX-RS in relation to Jersey and JSRs

前端 未结 2 1131
南笙
南笙 2020-12-16 16:33

I\'m trying to get my head around some concepts in Java:

  1. JSR(s): describe specifications, but carry no actual implementations. E.g. http://jsr311.java.net/ is
2条回答
  •  隐瞒了意图╮
    2020-12-16 17:08

    1. Yes, this isn't anything new. Think about JDBC, java provides the interfaces (Connection, Statement, ResultSet etc) but it is up to database vendors to provide implementations.

    2. If you're using a JSR-311 implementation like Jersey or Apache CXF then you'll annotate your classes with the javax.ws.rs annotations, such as @Path, @GET, @Produces etc. This is why you need to explicitly have JSR-311 as a maven dependency.

    3. Yes, usually. Have a look at the JSR list on wiki.

    4. You need both the JSR and the implementation. The annotations are in the JSR, the implementation provides supporting classes, such as com.sun.jersey.spi.container.servlet.ServletContainer.

    5. No, it is necessary to have both as dependencies (see point 4); you won't get classpath conflicts.

提交回复
热议问题