java配置JDBC时,用连接池出现错误NoClassDefFoundError: org/apache/commons/pool/KeyedObjectPoolFactory
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/pool/KeyedObjectPoolFactory
at JDBCtools.JDBCUtils.<clinit>(JDBCUtils.java:13)
at JDBCtools.Test.main(Test.java:7)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool.KeyedObjectPoolFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
解决方法:分析上面的错误,是缺少相应的类文件:需要下载并添加一个叫common-pool的jar包。
时间: 2024-12-23 20:16:38