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

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

根据报错信息可见,问题出在函数体第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<ConnectorProvider> iterator = ServiceFinder.find(ConnectorProvider.class).iterator();
            if (iterator.hasNext()) {
                this.connectorProvider = iterator.next();
            } else {
                this.connectorProvider = new HttpUrlConnectorProvider();
            }
        }

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

<dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-common</artifactId>
        <version>2.22</version>
</dependency>

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

参照:

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

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

猜你喜欢

转载自blog.csdn.net/figosoar/article/details/111603124