日期:2014-05-16 浏览次数:20435 次
用Myeclipse开发struts时,配置struts-config中的data-sources,出现java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource的解决方法
struts-config.xml文件中的data-sources是这样配置的
<data-sources> <data-source key="mysql" type="org.apache.commons.dbcp.BasicDataSource"> <set-property property="autoCommit" value="true"/> <set-property property="driverClassName" value="com.mysql.jdbc.Driver"/> <set-property property="url" value="jdbc:mysql://localhost:3306/javajavajava"/> <set-property property="maxCount" value="10"/> <set-property property="minCount" value="1"/> <set-property property="username" value="root"/> <set-property property="password" value="admin"/> </data-source> </data-sources>
启动Tomcat,结果出现下面的错误:
信息: Starting Servlet Engine: Apache Tomcat/6.0.13
2007-12-17 19:31:06 org.apache.struts.action.ActionServlet initModuleDataSources
严重: Initializing application data source mysql
java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:117)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
at org.apache.struts.action.ActionServlet.