URL*_*L87 25 java mysql servlets jar
当我在eclipse Dynamic Web Project
里面使用follow代码时servlet
,像这样:
@WebServlet("/CreateCustomerServlet")
public class CreateCustomerServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private void test() throws SQLException, ClassNotFoundException {
// use the JAR ...
Class.forName("com.mysql.jdbc.Driver");//here the exception
}
}
Run Code Online (Sandbox Code Playgroud)
抛出异常:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
在线:
Class.forName("com.mysql.jdbc.Driver");
在动态Web项目的Build路径中,我添加了jar:
mysql-connector-java-5.1.21-bin.jar
我添加了文件夹的快照,你可以看到它所需的jar -
JB *_*zet 37
如屏幕截图所示,mysql jar不会出现在Web App Libraries节点下.粘贴jar WebContent/WEB-INF/lib
,它将自动添加到and
webapp的运行时类路径的构建路径中(它将显示在Web App Libraries下).
Nas*_*din 25
刚才我解决了这个问题.
properties
你的项目.Deployment Assembly
- > add
- > Java Build Path Entries
.你完成了!
归档时间: |
|
查看次数: |
43815 次 |
最近记录: |