请帮帮我。
我有okhttp3和logging-interceptor 4.7.2版本。当我调用ONVIF getDeviceInformation时,“ Okhttp Dispatcher”线程中存在java.lang.NoSuchMethodError:okhttp3.internal.Platform.log。如果我设置okhttp3 3.14.7版本,则在“ Okhttp Dispatcher”线程中具有java.lang.NoSuchFieldError:INSTANCE。
<modelVersion>4.0.0</modelVersion>
<groupId>prj.group.id</groupId>
<artifactId>art.id</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.M4</version>
</parent>
<properties>
<java-version>1.8</java-version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>5.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg</artifactId>
<version>4.2.1-1.5.2</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg-platform</artifactId>
<version>4.2.1-1.5.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<dependency>
<groupId>be.teletask.onvif</groupId>
<artifactId>onvif</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.7.2</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>4.7.2</version>
</dependency>
<dependency>
<groupId>com.burgstaller</groupId>
<artifactId>okhttp-digest</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.2.RELEASE</version>
</plugin>
</plugins>
</build>
<repositories>
***
</repositories>
<pluginRepositories>
***
</pluginRepositories>
当我调用getDeviceInformation时onError方法出错
OnvifManager manager = new OnvifManager();
manager.setOnvifResponseListener( new OnvifResponseListener() {
@Override
public void onError(OnvifDevice device, int I, String s) {
System.out.println(s);
}
...
});
...
manager.getDeviceInformation(onvifDevice, (device, information) -> {
// Don't reach this code
information.getModel();
});
最佳答案
我有okhttp3和logging-interceptor 4.7.2版本。我有java.lang.NoSuchMethodError:okhttp3.internal.Platform.log
这是一个依赖性问题,
您正在使用 :
好的http-4.7.2
测井拦截器4.7.2
okhttp-digest-2.0
和
okhttp-digest-2.0的运行时依赖项是okhttp-4.0.1
Maven回购:https://mvnrepository.com/artifact/com.burgstaller/okhttp-digest/2.0
所以现在您有同一个库的两个不同版本
okhttp-digest-2.0中的1.okhttp-4.0.1
2.确定http-4.7.2
我们可以在图像中看到的log函数发生了变化(这是什么意思,它表示NoSuchMethodError:okhttp3.internal.Platform.log)
解决方案:
您可以更新okhttp-digest的版本,该版本可以与okhttp-4.7.2一起使用
如果不使用依赖okhttp的功能,则可以将其从okhttl-digest中排除。