错误信息:
严重: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [config/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'driverClassName' of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: Bean property 'driverClassName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableB eanFactory.applyPropertyValues(AbstractAutowireCapableB eanFactory.
at org.springframework.beans.factory.support.AbstractAutowireCapableB eanFactory.populateBean(AbstractAutowireCapableB eanFactory.
at org.springframework.beans.factory.support.AbstractAutowireCapableB eanFactory.doCreateBean(AbstractAutowireCapableB eanFactory.
at org.springframework.beans.factory.support.AbstractAutowireCapableB eanFactory.createBean(AbstractAutowireCapableB eanFactory.
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.
at org.springframework.beans.factory.support.DefaultSingletonBeanRegi stry.getSingleton(DefaultSingletonBeanRegi stry.
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.
at org.springframework.beans.factory.support.DefaultListableBeanFacto ry.preInstantiateSingletons (DefaultListableBeanFacto ry.
at org.springframework.context.support.AbstractApplicationConte xt.finishBeanFactoryInitial ization(AbstractApplicationConte xt.
at org.springframework.context.support.AbstractApplicationConte xt.refresh(AbstractApplicationConte xt.
at org.springframework.web.context.ContextLoader.configureAndRefreshWebAp plicationContext(ContextLoader.
at org.springframework.web.context.ContextLoader.initWebApplicationContex t(ContextLoader.
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.
at org.apache.catalina.core.StandardHost.addChild(StandardHost.
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:
解决方法:
从报错信息中可以看出是
[com.mchange.v2.c3p0.ComboPooledDataSource]是这个类下面的属性不正确,所以这里牵涉到dbcp和c3p0两种数据库连接池,在配置数据源的时候,使用这两种数据库连接池的时候,下面的属性是不一样的,这是问题的关键所在。所以只需要确定你用的是哪一种,然后去网上查一下,该类的属性按照对应的进行修改就行了。
dbcp和c3p0的比较:
dbcp相对来说比较高效,但是存在丢失连接的可能,而c3p0则比较稳定。所以个人推荐使用c3p0作为数据库连接池