如何更正应用程序的类路径,使其包含单个兼容版本

How to correct the classpath of your application so that it contains a single compatible version

我有一个微服务无法启动并出现以下错误消息:

2020-03-08T06:55:23.966752513Z ***************************
2020-03-08T06:55:23.966756613Z APPLICATION FAILED TO START
2020-03-08T06:55:23.966771414Z ***************************
2020-03-08T06:55:23.966775614Z 
2020-03-08T06:55:23.966779614Z Description:
2020-03-08T06:55:23.966783414Z 
2020-03-08T06:55:23.966787415Z An attempt was made to call the method okhttp3.HttpUrl.get(Ljava/lang/String;)Lokhttp3/HttpUrl; but it does not exist. Its class, okhttp3.HttpUrl, is available from the following locations:
2020-03-08T06:55:23.966791915Z 
2020-03-08T06:55:23.966795915Z     jar:file:/myapp/myapp.jar!/BOOT-INF/lib/okhttp-3.8.1.jar!/okhttp3/HttpUrl.class
2020-03-08T06:55:23.966865718Z 
2020-03-08T06:55:23.966876618Z It was loaded from the following location:
2020-03-08T06:55:23.966880919Z 
2020-03-08T06:55:23.966884919Z     jar:file:/myapp/myapp.jar!/BOOT-INF/lib/okhttp-3.8.1.jar!/
2020-03-08T06:55:23.966889119Z 
2020-03-08T06:55:23.966892919Z 
2020-03-08T06:55:23.966896719Z Action:
2020-03-08T06:55:23.966900719Z 
2020-03-08T06:55:23.966904520Z Correct the classpath of your application so that it contains a single, compatible version of okhttp3.HttpUrl
2020-03-08T06:55:23.966918320Z 

我没有直接使用 okhttp3,我使用的是两个使用 Microsoft keyvault 和文档库的库。 Microsoft 库正在使用 okhttp3 库。

此外,此服务在本地启动,但我仅在部署到 AWS 时才看到此问题。

如何解决?感谢您提供任何帮助,并提前致谢。

感谢和问候, dj

您正在从 2 个位置加载它

mvn dependency:tree

尝试在 pom.xml 中使用 maven 排除项以仅获取 okhttp3 库的一个实例。