有赞新零售社区

发帖
API使用问题»构建计划成功,部署成功,运行提示jar找不到

构建计划成功,部署成功,运行提示jar找不到

吴瑶(Wendy) 2022-04-22 727 浏览 3 评论 | 只看楼主 [打印]
构建计划成功,没有提示mysql的驱动jar找不到,部署也是成功的。 但是请求时提示:
can not find class: com.mysql.cj.jdbc.Driver

maven 中依赖:
<dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
</dependency>
后面尝试直接具体到版本<dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
   <version>8.0.28</version>
</dependency>
问题依旧。
用手机打开
收藏 ··· 回复
    王广江   白银   2022-04-22 | 只看该作者
    您好,辛苦检查一下应用的应用变量中是否有类似配置
    键:druid.datasource.driverClassName
    值:com.mysql.jdbc.Driver
    有赞的java框架是基于spingboot的,类似的通用技术问题可以到相关的技术论坛提问。
    https://blog.csdn.net/kingscoming/article/details/78824449
    • 吴瑶(Wendy) 2022-04-22
             
      spring.datasource.driver.class.name
      com.mysql.cj.jdbc.Driver  环境变量使用的是这个 ,这个问题比较奇怪,maven有jar依赖,我们项目生产没有问题 测试是因为长时间没有用被回收了。 异常日志报的是驱动类找到不,这个错误很明显,不是通用错误,和你发的连接没有关系啊。
    • 吴瑶(Wendy) 2022-04-22
      后台异常是:Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.Driver   你看我的maven 是有依赖的  使用有赞构建也没有报jar找不到 是正常的 部署后访问服务抛出这个驱动类找不到的异常。
    • 吴瑶(Wendy) 2022-04-22
      能否进入容器内部 容器实例:binvoice-7784dd546c-n74xc   看下是否没有下载下来对应的mysql驱动jar
    • 王广江 回复 吴瑶(Wendy) 2022-04-22
      您好,辛苦尝试将数据库驱动修改成com.mysql.jdbc.Driver后,再试下。
      同时这边有查到您很久没有发布过项目了,2021年12月30日有做过框架升级,您可以看下相关公告。
      https://doc.youzanyun.com/resource/doc/4459/4459

    按照你的更换了驱动提示数据库连接不上了,连接的是(jdbc:mysql://10.60.235.92:3306/binvoice?serverTimezone=GMT%2B8)控制台mysql 开发环境没有显示连接的地方 我也不清楚这个地址是否正确?该如何判断:

    Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.exceptions.PersistenceException:
    ### Error querying database.  Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    ### The error may exist in mappers/SellerTicketMapper.xml
    ### The error may involve com.youzan.cloud.binvoice.dal.mapper.SellerTicketMapper.selectSellerByUpdateTime
    ### The error occurred while executing a query
    ### Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

      已经可以了。

        1跳至
        您需要登录后才可以回帖 登录 | 立即注册

        本版积分规则

        复制链接
        新浪微博
        QQ空间
        微信扫码
        • 回复

        • 评分

        客服工作时间是9:00-18:00,客服妹子当前不在线,若不能及时回复请谅解。试试右上角的搜索吧,论坛有丰富的经验贴、公告贴,相信一定能够帮到您~

        复制成功