ssh 一个项目多个数据库
我找到例子,SPRING配置如下:<beanid="sessionFactoryCars"class="org.springframework.orm.hibernate...
我找到例子,SPRING 配置如下:
<bean id="sessionFactoryCars"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cars.cfg.xml" />
</bean>
<!-- car beans -->
<bean id="carsDao" class="cars.dao.CarsDao">
<property name="sessionFactory" ref="sessionFactoryCars"/>
</bean>
<!-- -->
<bean id="carsService" class="cars.service.CarsService">
<property name="dao" ref="dao"></property>
</bean>
<bean id="capply" class="cars.action.Apply" >
<property name="carsService" ref="carsService"></property>
</bean>
-------------------
<!-- user Factory -->
<bean id="sessionFactoryUser"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.user.cfg.xml" />
</bean>
<!-- user beans -->
<bean id="userAct" class="pub.user.action.UserManager" scope="prototype"><!-- singleton -->
<property name="userService" ref="userService"></property>
</bean>
<bean id="userService" class="pub.user.service.UserManagerService">
<property name="dao" ref="dao"></property>
</bean>
<bean id="dao" class="pub.user.dao.BaseDao">
<property name="sessionFactory" ref="sessionFactoryUser"/>
</bean>
------------
启动一直出错:
Error creating bean with name 'carsService' defined in ServletContext resource [/WEB-INF/applicationContextCars.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'dao' of bean class [cars.service.CarsService]: Bean property 'dao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
第二个贴错了,是以下:
<!-- car Factory -->
<bean id="sessionFactoryCars"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cars.cfg.xml" />
</bean>
<!-- car beans -->
<bean id="carsDao" class="cars.dao.CarsDao">
<property name="sessionFactory" ref="sessionFactoryCars"/>
</bean>
<bean id="carsService" class="cars.service.CarsService">
<property name="carsDao" ref="carsDao"></property>
</bean>
<bean id="capply" class="cars.action.Apply" >
<property name="carsService" ref="carsService"></property>
</bean>
============================
可能是我没有说明清楚,不过问题我已经解决,是JAVABEAN里没写SETTER方法。 展开
<bean id="sessionFactoryCars"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cars.cfg.xml" />
</bean>
<!-- car beans -->
<bean id="carsDao" class="cars.dao.CarsDao">
<property name="sessionFactory" ref="sessionFactoryCars"/>
</bean>
<!-- -->
<bean id="carsService" class="cars.service.CarsService">
<property name="dao" ref="dao"></property>
</bean>
<bean id="capply" class="cars.action.Apply" >
<property name="carsService" ref="carsService"></property>
</bean>
-------------------
<!-- user Factory -->
<bean id="sessionFactoryUser"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.user.cfg.xml" />
</bean>
<!-- user beans -->
<bean id="userAct" class="pub.user.action.UserManager" scope="prototype"><!-- singleton -->
<property name="userService" ref="userService"></property>
</bean>
<bean id="userService" class="pub.user.service.UserManagerService">
<property name="dao" ref="dao"></property>
</bean>
<bean id="dao" class="pub.user.dao.BaseDao">
<property name="sessionFactory" ref="sessionFactoryUser"/>
</bean>
------------
启动一直出错:
Error creating bean with name 'carsService' defined in ServletContext resource [/WEB-INF/applicationContextCars.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'dao' of bean class [cars.service.CarsService]: Bean property 'dao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
第二个贴错了,是以下:
<!-- car Factory -->
<bean id="sessionFactoryCars"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cars.cfg.xml" />
</bean>
<!-- car beans -->
<bean id="carsDao" class="cars.dao.CarsDao">
<property name="sessionFactory" ref="sessionFactoryCars"/>
</bean>
<bean id="carsService" class="cars.service.CarsService">
<property name="carsDao" ref="carsDao"></property>
</bean>
<bean id="capply" class="cars.action.Apply" >
<property name="carsService" ref="carsService"></property>
</bean>
============================
可能是我没有说明清楚,不过问题我已经解决,是JAVABEAN里没写SETTER方法。 展开
展开全部
/applicationContextCars.xml
应该是这个配置文件中有地方没有配置对,或者是你没有配置的
恩,对,是那个样子的
[cars.service.CarsService]: Bean property 'dao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
这两句就可以看出来的。
应该是这个配置文件中有地方没有配置对,或者是你没有配置的
恩,对,是那个样子的
[cars.service.CarsService]: Bean property 'dao' 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="dao" class="pub.user.dao.BaseDao">
<property name="sessionFactory" ref="sessionFactoryUser"/>
</bean>
这个放到
<bean id="carsDao" class="cars.dao.CarsDao">
<property name="sessionFactory" ref="sessionFactoryCars"/>
</bean>
前面试试
<bean id="dao" class="pub.user.dao.BaseDao">
<property name="sessionFactory" ref="sessionFactoryUser"/>
</bean>
这个放到
<bean id="carsDao" class="cars.dao.CarsDao">
<property name="sessionFactory" ref="sessionFactoryCars"/>
</bean>
前面试试
追问
能说一下原因吗?
追答
这样可以解决吗。因为我好像遇到类似问题,就是这样解决的。因为我觉得dao是其它dao的父类。所以必须先设定父类
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-07-06
展开全部
神马意思?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
什么问题
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
启动一直出错说明你的配置里出错了,看下你的web。xml
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询