0
回答
dataSource配置dbcp 为什么tomcat启动时会抛出找不到c3p0
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

我的applicationContext 里面明明配置的是dbcp,tomcat启动的时候 为什么会提示找不到c3po

2015-3-18 14:21:41 org.springframework.web.context.ContextLoader initWebApplicationContext
严重: Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.mchange.v2.c3p0.ComboPooledDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.mchange.v2.c3p0.ComboPooledDataSource

而且我的项目中也添加了dbcp的jar包

下面是我的配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:p="http://www.springframework.org/schema/p"
     xmlns:aop="http://www.springframework.org/schema/aop"
     xmlns:tx="http://www.springframework.org/schema/tx"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://www.springframework.org/schema/aop
         http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
         http://www.springframework.org/schema/tx
         http://www.springframework.org/schema/tx/spring-tx-3.0.xsd" >

<context:component-scan base-package="com"/>
         
<bean id="sessionFactory"
	class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
	p:dataSource-ref="dataSource">
	<property name="mappingLocations">
		<list>
			<value>classpath*:/com/baobaotao/ReqType.hbm.xml</value>
		</list>
	</property>
	<property name="hibernateProperties">
		<props>
			<prop key="hibernate.dialect">
				org.hibernate.dialect.MySQLDialect
			</prop>
			<prop key="hibernate.show_sql">
				true
			</prop>
		</props>
	</property>
</bean>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
	destroy-method="close"
	p:url="jdbc:oracle:thin:@localhost:1521:orcl"
	p:driverClassName="oracle.jdbc.driver.OracleDriver"
	p:username="testplatform"
	p:password="testplatform"/>
	
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"
	p:sessionFactory-ref="sessionFactory"/>
	
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"
	p:sessionFactory-ref="sessionFactory"/>  	
	
</beans>



举报
zzbutcher
发帖于3年前 0回/340阅
顶部