简体   繁体   English

我是否需要在服务器端依赖“jersey-client”来支持用它实现的客户端?

[英]Do I need the "jersey-client" dependency on server side to support clients implemented with it?

I am implementing a RESTful server with Jersey and I am currently struggling to set up my maven dependencies correctly.我正在使用 Jersey 实现一个 RESTful 服务器,我目前正在努力正确设置我的 maven 依赖项。 I use an Apache Tomcat as the servlet container.我使用 Apache Tomcat 作为 servlet 容器。 According to the documentation I need to include the jersey-client dependency only when I am using the JAX-RS Client.根据文档,我仅在使用 JAX-RS 客户端时才需要包含jersey-client依赖项。

The way I understand that, is that I need to include the client dependency in my server side application to support clients developed with jersey. Is that correct?我的理解是,我需要在服务器端应用程序中包含客户端依赖项以支持使用 jersey 开发的客户端。对吗?

Or is it meant in the way, that the client dependency is actually only needed in the client application?或者它的意思是,客户端依赖实际上只在客户端应用程序中需要?

The Jersey client is solely meant to be used as an HTTP client to make requests to other remote servers. Jersey 客户端仅用作 HTTP 客户端以向其他远程服务器发出请求。 That's it.而已。 You only need the client if you need to make requests to remote servers from inside your server application.如果您需要从服务器应用程序内部向远程服务器发出请求,您只需要客户端。 The client should already be automatically pulled in by the server dependencies though.但是,客户端应该已经被服务器依赖项自动拉入。 Whether or not some other client is using the Jersey client has no bearing on whether or not you need to include the Jersey client dependency in your Jersey server app.其他客户端是否使用 Jersey 客户端与您是否需要在 Jersey 服务器应用程序中包含 Jersey 客户端依赖项无关。

While one indeed doesn't need jersey-client on the Server side application, please pay attention that it is a dependency of the jersey-container-servlet , as mentioned in the accepted answer.虽然服务器端应用程序确实不需要jersey-client ,但请注意它是jersey-container-servlet的依赖项,如已接受的答案中所述。

In fact, if you'd try to exclude jersey-client transitively, the app won't start, but fail on class ( ClientConfig something) not found exception, so don't.事实上,如果你试图传递地排除jersey-client ,应用程序将不会启动,但会在 class( ClientConfig something)未找到异常时失败,所以不要。

Observed as of 2022-03 (Jersey v3.0.4)从 2022-03 开始观察(泽西岛 v3.0.4)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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