db.properties
jdbc.driverClassName=com.gjt.mm.mysql.Driver
#jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/xxx
jdbc.username=xxx
jdbc.password=xxx pom.xml
pom.xml
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.13</version>
</dependency>
错误提示
信息: Loading XML bean definitions from class path resource [applicationContext.xml]
2010-8-9 21:02:41 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@133f1d7]: org.springframework.beans.factory.support.DefaultListableBeanFactory@efd552
2010-8-9 21:02:41 org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
信息: Loading properties file from class path resource [db.properties]
2010-8-9 21:02:42 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@efd552: defining beans [propertyConfigurer,datasource,jdbcTemplate]; root of factory hierarchy
Exception in thread "main" org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.gjt.mm.mysql.Driver'
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1429)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at com.freeSoft.GenerateMain.main(GenerateMain.java:23)
Caused by: java.lang.ClassNotFoundException: com.gjt.mm.mysql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1420)
... 3 more
修复
jdbc.driverClassName=com.gjt.mm.mysql.Driver ==>jdbc.driverClassName=com.mysql.jdbc.Driver
--转自