spring的xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@localhost:1521:Orcl">
</property>
<property name="username" value="j2ee"></property>
<property name="password" value="j2ee"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"
value="dataSource">
</property>
<property name="mappingResources">
<list>
<value>com/tianlesoftware/guestbook/model/Guestbook.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
</props>
</property>
</bean>
<bean id="guestbookDao"
class="com.tianlesoftware.guestbook.dao.hibernate.GuestbookDaoHibernate"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="guestbookManager"
class="com.tianlesoftware.guestbook.service.impl.GuestbookManagerImpl"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
<property name="guestbookDao">
<ref bean="guestbookDao" />
</property>
</bean></beans>
启动tomcat后就报错了:
2008-7-16 14:49:47 org.apache.catalina.core.StandardContext addApplicationListener
信息: The listener "org.springframework.web.context.ContextLoaderListener" is already configured for this context. The duplicate definition has been ignored.
2008-7-16 14:49:49 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
2008-7-16 14:49:55 org.apache.catalina.core.StandardContext listenerStart
严重: 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 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found