例外说明:配置错误。在Netbeans中找不到类[com.mysql.jdbc.Driver]

时间:2017-03-25 18:34:43

标签: java mysql maven jdbc netbeans

首先,我阅读了有关该问题的所有帖子,但我无法解决我的问题。我有一个带maven的web应用程序,我正在使用glassfish& MySQL的。当我想从数据库接收信息时,我接受了这个错误。我会告诉你错误:

enter image description here

这是我的<%@page import="tr.kasim.cc.app.Application"%> <%@page import="tr.kasim.cc.model.SignUp"%> <%@page import="java.util.List"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="css/index.css"></link> <title>User Listesi</title> </head> <body><center> <p class="title">User Listesi</p> <table style="border: black 1px solid"> <tr> <td>loginName</td> <td>password</td> <td>eMail</td> <td>userName</td> <td>userDate</td> <td>userJob</td> <td>userTelephone</td> <td>userCity</td> <td>userGenderId</td> </tr> <% List<SignUp> users = Application.getApp().getMainService().getUsers(); for (SignUp user : users) { %> <tr> <td><%=(user.getUserLoginName())%></td> <td><%=(user.getUserPassword())%></td> <td><%=(user.getUserEMail())%></td> <td><%=(user.getUserName())%></td> <td><%=(user.getUserDate())%></td> <td><%=(user.getUserJob())%></td> <td><%=(user.getUserTelephone())%></td> <td><%=(user.getUserCity())%></td> <td><%=(user.getUserGenderId())%></td> </tr> <%} %> </table> <br/><br><br> <a href="index.jsp">Return HomePage</a><br> </center></body> </html> 页面,我试图从数据库中获取信息:

<groupId>tr.kasim</groupId>
    <artifactId>CourseCenter</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>

    <name>CourseCenter</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
    </dependencies>

这里是我的pom.xml依赖项(我为mysql连接添加了依赖项):

#install PIL (Pillow) via Pip

from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw 

#position of Text
x = 50
y = 50

#font color as tuple
color = (255, 255, 255)

#download the image to the local system and open it
img = Image.open("1.jpg")

#draw image and prepare font
draw = ImageDraw.Draw(img)
font = ImageFont.truetype('arial.ttf', size=30)

#draw text on image
draw.text((x, y),"Sample Text", color,font=font)

#save the new image, that contains the text
img.save('sample-out.jpg')

此外,我将mysql设为依赖项: mysql artifacted。 我不知道该怎么办。 请帮帮我,谢谢..

1 个答案:

答案 0 :(得分:0)

当您处理Web应用程序时,您需要再记住依赖库和jar应该在WEB-INF/lib文件夹下可用的一点,以便让您的Web / Application Server(例如:GlassFish在您的文件夹中) case,here)在运行时识别它们。

将必要的附属jar复制到上述文件夹中,然后重新部署以解决问题。

<强>(OR)

您也可以执行以下操作: 只需将mysql-connector-java-5.1.x.jar复制到JAVA_HOME\jre\lib\ext内,即使这样也可以确保您的问题得到解决。