xml配置:<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"> <property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property> <property name="url">
<value>jdbc:mysql://localhost/auth?useUnicode=true&characterEncoding=utf-8</value>
</property> <property name="username">
<value>root</value>
</property> <property name="password">
<value>root</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"> <ref local="dataSource" /> </property>
<property name="lobHandler" ref="lobHandler"/>
</bean>
<!-- lob字段的配置 -->
<bean id="nativeJdbcExtractor"
class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"
lazy-init="true"/>
<bean id="lobHandler"
class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true">
<property name="nativeJdbcExtractor">
<ref local="nativeJdbcExtractor"/>
</property>
</bean>
其余的配置省略了。
太多 就不贴了
主要抛以下异常:信息: Loading Spring root WebApplicationContext
2011-3-9 16:47:06 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.appfuse.webapp.listener.StartupListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/hibernate_context.xml]: Can't resolve reference to bean 'lobHandler' while setting property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandler' defined in ServletContext resource [/WEB-INF/hibernate_context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'nativeJdbcExtractor' of bean class [org.springframework.jdbc.support.lob.DefaultLobHandler]: Bean property 'nativeJdbcExtractor' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandler' defined in ServletContext resource [/WEB-INF/hibernate_context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'nativeJdbcExtractor' of bean class [org.springframework.jdbc.support.lob.DefaultLobHandler]: Bean property 'nativeJdbcExtractor' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.NotWritablePropertyException: Invalid property 'nativeJdbcExtractor' of bean class [org.springframework.jdbc.support.lob.DefaultLobHandler]: Bean property 'nativeJdbcExtractor' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
不知道在哪地方配置错误了
求解~~
解决了还会加分、谢谢大家
destroy-method="close"> <property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property> <property name="url">
<value>jdbc:mysql://localhost/auth?useUnicode=true&characterEncoding=utf-8</value>
</property> <property name="username">
<value>root</value>
</property> <property name="password">
<value>root</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"> <ref local="dataSource" /> </property>
<property name="lobHandler" ref="lobHandler"/>
</bean>
<!-- lob字段的配置 -->
<bean id="nativeJdbcExtractor"
class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"
lazy-init="true"/>
<bean id="lobHandler"
class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true">
<property name="nativeJdbcExtractor">
<ref local="nativeJdbcExtractor"/>
</property>
</bean>
其余的配置省略了。
太多 就不贴了
主要抛以下异常:信息: Loading Spring root WebApplicationContext
2011-3-9 16:47:06 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.appfuse.webapp.listener.StartupListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/hibernate_context.xml]: Can't resolve reference to bean 'lobHandler' while setting property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandler' defined in ServletContext resource [/WEB-INF/hibernate_context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'nativeJdbcExtractor' of bean class [org.springframework.jdbc.support.lob.DefaultLobHandler]: Bean property 'nativeJdbcExtractor' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandler' defined in ServletContext resource [/WEB-INF/hibernate_context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'nativeJdbcExtractor' of bean class [org.springframework.jdbc.support.lob.DefaultLobHandler]: Bean property 'nativeJdbcExtractor' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.NotWritablePropertyException: Invalid property 'nativeJdbcExtractor' of bean class [org.springframework.jdbc.support.lob.DefaultLobHandler]: Bean property 'nativeJdbcExtractor' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
不知道在哪地方配置错误了
求解~~
解决了还会加分、谢谢大家
<bean id="nativeJdbcExtractor"
class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"
lazy-init="true"/>
<bean id="lobHandler"
class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true">
<property name="nativeJdbcExtractor">
<ref local="nativeJdbcExtractor"/>
</property>
</bean>
配这个是干嘛的?
<bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler"
lazy-init="true" /> <bean id="nativeJdbcExtractor" lazy-init="true"
class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" />
<!-- 设置本地 Jdbc 对象抽取器 读操作-->
<bean id="oracleLobHandler" lazy-init="true"
class="org.springframework.jdbc.support.lob.OracleLobHandler">
<property name="nativeJdbcExtractor">
<ref bean="nativeJdbcExtractor" />
</property>
</bean>
等我明天看看
估计就是这的错误
应该是DefaultLobHandler 所对应的 是
<bean id="defaultLobHandler"
class="org.springframework.jdbc.support.lob.DefaultLobHandler"
lazy-init="true" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="lobHandler" ref="defaultLobHandler"/>
</bean>
<!-- lob字段的配置 -->
<bean id="nativeJdbcExtractor"
class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"
lazy-init="true"/>
<bean id="defaultLobHandler"
class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true">
</bean>以上才是正确的配置、、、。。
忘了。。
我用的是Mysql的数据库
像mysql这种普通数据库应该用DefaultLobHandler