java.lang.ClassNotFoundException: com.mysql.jdbc.Driver的问题

出现这个问题极有可能是加载全路径找到配置文件的时候路径出现了空格

解决办法:
URL对象转换成字符串前,先调用toURI()方法,如下

ClassLoader classLoader = JDBCUtils.class.getClassLoader();
URL res  = classLoader.getResource("jdbc.properties");
String path = res.toURI().getPath();//URL对象转换成字符串前,先调用toURI()方法
System.out.println(path);
//输出:D:/IntelliJ IDEA 2019.3.1/Web-Code/out/production/day04-jdbc/jdbc.properties

https://blog.csdn.net/qq_38454176/article/details/104101972

posted @ 2020-04-30 22:09  Amber-  阅读(489)  评论(0编辑  收藏  举报