简体   繁体   中英

In application I have acsess to JDBC driver (exception java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver)

The same project servlet application does not work, but "hello world" method, in the same project, yes. Here the picture ofproject.

在此处输入图片说明

Versions:

Intellij IDEA - 2018.2

mySQL driver version: 8.0.11 , driver com.mysql.cj.jdbc.Driver

servlet 9.0.81

In Code:

Class.forName(dbDriver).newInstance();
dbConnection = DriverManager.getConnection(connectionUrl, userName, password);

Exception:

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

BTW:

The same exception I receive also without mysql dependency in PON.xml

So, this is issue or I missing something. Thanks

UPDATE 在此处输入图片说明

SOLVED: We need to add library in Artifact .

请确保在应用程序服务器上部署的Artifact配置中还包含所有必需的jar。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM