Action:Correct the classpath of your application so that it contains compatible versions of the classes io.minio.S3Base and okhttp3.RequestBody
這個錯誤是我在整合minio時報的錯,說實話遇到這個錯誤我還是很頭大的,因為之前在springboot項目中整合過一次minio,當時報的錯誤跟這個差不多,都是okhttp版本依賴問題,之前是因為,我的minio依賴里面自帶的okhttp包的版本過低,需要將minio包中的okhttp包剔除,自己手動引進一個更高版本的okhttp包。
<!--maven引入minio排除okhttp依賴并添加高版本的okhttp依賴-->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.5.2</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.0</version>
</dependency>
就像上述代碼一樣,這樣就可以解決okhttp版本的問題。但是這次報的錯誤跟上次幾乎一樣,追根揭底也是okhttp包版本問題,這次是版本沖突問題。
這就是這個錯誤奇怪的地方,發(fā)現(xiàn)是版本沖突后,我查看了這個項目的版本依賴,但是沒有發(fā)現(xiàn)有關(guān)okhttp的版本沖突存在。
又從頭看了一下報錯信息,發(fā)現(xiàn)了一個奇怪的地方。
The called method's class, okhttp3.RequestBody, is available from the following locations:
jar:file:/D:/repository/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar!/okhttp3/RequestBody.class
The called method's class hierarchy was loaded from the following locations:
okhttp3.RequestBody: file:/D:/repository/com/squareup/okhttp3/okhttp/3.14.9/okhttp-3.14.9.jar
它不知道從哪給我加載了一個3.14.9版本的okhttp,而我引入的依賴是4.9.0的版本,然后我又看了一下我項目引入的依賴庫,確實找到了兩個版本的okhttp。
然后我就開始找這個3.14.9版本的okhttp是從哪里引進來的,自己折騰了一大晌還是沒有找到,后來就放棄了,等到第二天再來看這個錯誤的時候,在這個okhttp依賴旁邊發(fā)現(xiàn)了這個
本來也是沒發(fā)現(xiàn)什么異常,就是實在沒法了點了一下,就進到了這里
嘿,擱這找到了,往上翻,找到他的版本號
好家伙,原來擱這了,那現(xiàn)在就是想辦法把這個版本號給覆蓋掉就行了,在我的這個項目的父工程里加入這個okhttp的版本號,在這個項目里引用這個版本號,重新啟動,問題解決。文章來源:http://www.zghlxwxcb.cn/news/detail-730987.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-730987.html
<!--maven引入minio排除okhttp依賴并添加高版本的okhttp依賴-->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.5.2</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp3.version}</version>
</dependency>
到了這里,關(guān)于整合minio時出現(xiàn)的錯誤的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!