Solved: java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver

In a JavaWeb project, I searched for a long time but couldn't find a solution. Finally, the problem was solved by copying the driver to tomcat's lib.

It can be checked by the following methods:

Method 1: Copy the jar to tomcat's lib:

Find the tomcat directory and enter the lib inside:

 Copy the jdbc jar package into it:

 Then restart the server, solved!

Method 2: Add project structure

Find the project structure and add the driver to it:

Method 3: Add the jar package at the Mysql data source:

 

 

Guess you like

Origin blog.csdn.net/weixin_60414376/article/details/130743623