ssm项目报okhttp3/OkHttpClient

问题遇到的现象和发生背景

微信小程序开发平台调用本地ssm项目接口后用ssm项目调用其他接口时报错
微信小程序调用本地接口没问题,ssm项目调用
18:46:10.266 [http-nio-9090-exec-6] DEBUG org.springframework.web.servlet.DispatcherServlet - Failed to complete request: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: okhttp3/OkHttpClient

用代码块功能插入代码,请勿粘贴截图
@RequestMapping(value = "/code")
@ResponseBody
public void code(Employee employee) throws IOException {
    System.out.println("1111111111111111111111111111111111111111111111111111111111111111111111"+  employee.getEmpName());
    String url=".https://api.weixin.qq.com/sns/jscode2session ";   //这边的url是微信小程中这个接口:有些隐私内容所有隐藏掉了 url 反正没问题
    System.out.println(url+"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");


    OkHttpClient okHttpClient =  new OkHttpClient();
    Request request = new Request.Builder().url(url).build();
    Response response= okHttpClient.newCall(request).execute();

    if (response.isSuccessful()){
        String body = response.body().string();
        System.out.println(body+"3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333");
    }



}
运行结果及报错内容

18:46:10.266 [http-nio-9090-exec-6] DEBUG org.springframework.web.servlet.DispatcherServlet - Failed to complete request: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: okhttp3/OkHttpClient

我想要达到的结果

成功访问这个接口

是不是存在多个版本

okhttp3这个包没导入成功

看样子是包没倒入报错了 也有可能是版本冲突了

检查下是不是okhttp3包冲突了,存在多个版本

maven依赖冲突了, 题主, 教你一招怎么解决依赖冲突
软件: Idea2021.2.2, 图一: 点击maven窗口小图标展示依赖的图表

img


图2,红色线表示冲突, 其实很多情况都存在红色线的, 但是也能正常运行, 出问题了就需要解决了
这有几篇idea maven diagram使用教程的博客, idea的类图UML也很强大
https://www.cnblogs.com/reboot30/p/11911544.html
https://blog.csdn.net/qq_36555038/article/details/97266502
https://blog.jetbrains.com/idea/2010/05/maven-dependencies-diagram/

img

图3, 和图2比较, 说明slf4j-api被两个jar 依赖 了, 那两个需要的版本不一样

img

通过在线翻译报错信息,分析问题因素如下:

img


https证书的问题,
tomcat服务器路径和发布路径不一致所导致,主要检查Server path和Deploy path路径,
参考链接,期望对你有所启发:https://blog.csdn.net/qq_43795348/article/details/107207195