当前位置:   article > 正文

Cannot find class: com.mysql.cj.jdbc.Driver

cannot find class: com.mysql.cj.jdbc.driver

找了好多错误,也改了很多地方,最好不信胁还是改成了8.0.28的版本,没想到,还真对了。

  1. E:\Java\Environment\jdk1.8\bin\java.exe "-javaagent:D:\AppAdd1\idea\IntelliJ IDEA 2021.3.2\lib\idea_rt.jar=58630:D:\AppAdd1\idea\IntelliJ IDEA 2021.3.2\bin" -Dfile.encoding=UTF-8 -classpath E:\Java\Environment\jdk1.8\jre\lib\charsets.jar;E:\Java\Environment\jdk1.8\jre\lib\deploy.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\access-bridge-64.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\cldrdata.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\dnsns.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\jaccess.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\jfxrt.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\localedata.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\nashorn.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\sunec.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\sunjce_provider.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\sunmscapi.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\sunpkcs11.jar;E:\Java\Environment\jdk1.8\jre\lib\ext\zipfs.jar;E:\Java\Environment\jdk1.8\jre\lib\javaws.jar;E:\Java\Environment\jdk1.8\jre\lib\jce.jar;E:\Java\Environment\jdk1.8\jre\lib\jfr.jar;E:\Java\Environment\jdk1.8\jre\lib\jfxswt.jar;E:\Java\Environment\jdk1.8\jre\lib\jsse.jar;E:\Java\Environment\jdk1.8\jre\lib\management-agent.jar;E:\Java\Environment\jdk1.8\jre\lib\plugin.jar;E:\Java\Environment\jdk1.8\jre\lib\resources.jar;E:\Java\Environment\jdk1.8\jre\lib\rt.jar;E:\Java\Project\maven\mybatis-demo\target\classes;C:\Users\lenovo\.m2\repository\org\mybatis\mybatis\3.5.5\mybatis-3.5.5.jar;C:\Users\lenovo\.m2\repository\mysql\mysql-connector-java\5.1.34\mysql-connector-java-5.1.34.jar;C:\Users\lenovo\.m2\repository\org\slf4j\slf4j-api\1.5.6\slf4j-api-1.5.6.jar;C:\Users\lenovo\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\lenovo\.m2\repository\ch\qos\logback\logback-core\1.0.6\logback-core-1.0.6.jar com.example.test.MyBatisDemo1
  2. Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
  3. ### Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.Driver
  4. ### The error may exist in UserMapper.xml
  5. ### The error may involve test.selectAll
  6. ### The error occurred while executing a query
  7. ### Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.Driver
  8. at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
  9. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
  10. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
  11. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:135)
  12. at com.example.test.MyBatisDemo1.main(MyBatisDemo1.java:27)
  13. Caused by: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.Driver
  14. at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.initializeDriver(UnpooledDataSource.java:244)
  15. at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:223)
  16. at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:219)
  17. at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:95)
  18. at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:432)
  19. at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:89)
  20. at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:139)
  21. at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:61)
  22. at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:337)
  23. at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:86)
  24. at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
  25. at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
  26. at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
  27. at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
  28. at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:89)
  29. at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
  30. ... 3 more
  31. Process finished with exit code 1

回去又试了一遍,确实是mysql的问题,我之前写的是5.1.34,还是出错,改成了8.0.28,好了就。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/618457
推荐阅读
相关标签
  

闽ICP备14008679号