Java jersey相关问题 java.lang.NoSuchFieldError: EXCLUDE_EMPTY

长长的一大段报错信息,点开最近的一次调用。 根据报错信息可见,问题出在函数体第2行 /*** Default configuration state cons

长长的一大段报错信息,点开最近的一次调用。

根据报错信息可见,问题出在函数体第2行

        /*** Default configuration state constructor with {@link StateChangeStrategy "identity"}* state change strategy.** @param client bound parent Jersey client.*/State(final JerseyClient client) {this.strategy = IDENTITY;this.commonConfig = new CommonConfig(RuntimeType.CLIENT, ComponentBag.EXCLUDE_EMPTY);this.client = client;final Iterator iterator = ServiceFinder.find(ConnectorProvider.class).iterator();if (iterator.hasNext()) {this.connectorProvider = iterator.next();} else {this.connectorProvider = new HttpUrlConnectorProvider();}}

在maven中查看依赖项,在pom.xml中添加如下声明即可。

org.glassfish.jersey.corejersey-common2.22

其中,version版本号由你决定。比如我使用的是2.5.1版本。

 

 

参照:

使用jersey(2.5.1)编写Java REST客户端

https://blog.csdn.net/xiaofanku/article/details/48900409