[英]JAX-RS in relation to Jersey and JSRs
I'm trying to get my head around some concepts in Java: 我试图了解Java中的一些概念:
Am I completely off or onto someting? 我是完全不喜欢的吗?
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. 想想JDBC,java提供了接口(
Connection
, Statement
, ResultSet
等),但是由数据库供应商提供实现。
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. 如果您正在使用像Jersey或Apache CXF这样的JSR-311实现,那么您将使用
javax.ws.rs
注释来注释您的类,例如@GET
@Path
, @GET
, @GET
@Produces
等。这就是您需要明确的将JSR-311作为maven依赖。
Yes, usually. 是的,通常。 Have a look at the JSR list on wiki .
看看wiki上的JSR列表 。
You need both the JSR and the implementation. 您需要JSR和实现。 The annotations are in the JSR, the implementation provides supporting classes, such as
com.sun.jersey.spi.container.servlet.ServletContainer
. 注释在JSR中,实现提供了支持类,例如
com.sun.jersey.spi.container.servlet.ServletContainer
。
No, it is necessary to have both as dependencies (see point 4); 不,有必要兼顾两者(见第4点); you won't get classpath conflicts.
你不会得到类路径冲突。
Other than these, you're right. 除此之外,你是对的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.