Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[重要] 新版本依赖会导致 NoSuchMethod 异常 #222

Open
zhuangjiaju opened this issue Feb 21, 2025 · 1 comment
Open

[重要] 新版本依赖会导致 NoSuchMethod 异常 #222

zhuangjiaju opened this issue Feb 21, 2025 · 1 comment

Comments

@zhuangjiaju
Copy link

zhuangjiaju commented Feb 21, 2025

现象:
Image

导致结果:
只要有二方或者三方包引用了 1.5的版本,且使用了 get 或者post 方法。
其他项目在使用这个二方或者三方包的时候,必须确保也是1.5版本,如果当前项目是1.6版本 直接会报错。
get 作为一个提别基础的方法,兼容性要做好。

原因:

版本1

Image

版本2

Image

以上2个方法都可以使用 一个参数调用,所以没啥问题。

Image

但是有个场景提别要注意: 假设Forest.get(url) 这个代码写在一个二方包,然后二方包打包的时候用的版本1 ,然后项目中引入的是版本2 , 这个使用你调用二方包的方法,二方包再去调用 Forest.get(url) 会提示:NoSuchMethodError。但是你在项目里面调用 Forest.get(url) 是正常的。

简单的说: 你调用任何二方包、三方包,他再去调用其他包的任何方法都会校验签名,签名不一样就会报错,而不是方法能调通就行。

@mySingleLive
Copy link
Collaborator

这个问题应该是版本冲突,但比较奇怪的是,Forest.get方法应该是很老的版本就存在的方法,新版本也都是向下兼容的,不可能把这个方法删掉。
所以我想知道,你的项目中使用的最早的Forest版本是多少

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants