Does the parameter type of the setter match the return type of the getter?

[align=left][/align]当出现这个错误时应该就是你的bean.xml中的<property name="guohao"></property>
这个bean在相应的java类中没有set方法,这个在搭框架的时候特别容易犯错.
这里分析一下bean.xml


[size=xx-small][/size][size=xx-small][/size]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
>
<context:annotation-config/>
[color=red]<bean id="mydataSource"[/color]class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName"value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:ORCL"/>
<property name="username" value="scott"/>
<property name="password" value="tiger"/>
</bean>

[color=red]<bean id="mySessionFactory"[/color] class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="mydataSource"/>
<property name="mappingResources">
<list>
<value>com/guohao/rw/userpass/bean/UserInfor.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.OracleDialect
</value>
</property>
</bean>

[color=red]<bean id="txManager"[/color]class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="select*" read-only="true"/>
<tx:method name="get*" read-only="true"/>
<tx:method name="query*" read-only="true"/>


</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="busiServiceOperation" expression="execution(* com.guohao.rw.service..*.*(..)) "/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="busiServiceOperation"/>
</aop:config>

[color=red]<bean id="userPassDao" [/color]class="com.guohao.rw.userpass.dao.UserPassDaoImpl" >
<property name="sessionFactory">
<ref bean="mySessionFactory" />
</property>
</bean>

[color=red]<bean id="userPassService" [/color]class="com.guohao.rw.userpass.service.UserPassServiceImpl">
<property name="userPassDao">
<ref bean="userPassDao" />
</property>
</bean>

[color=red]<bean id="userPass" [/color]class="com.guohao.rw.userpass.action" scope="prototype">
<property name="userPassService">
<ref bean="userPassService" />
</property>
</bean>

</beans>


这里面property 的name是不能变的,比如: bean id="mySessionFactory中property dataSource的name只能为dataSource ref后面的可以随便取
<bean id="txManager"中<property name="sessionFactory" ref="mySessionFactory"/>
name只能为sessionFactory,ref后面的可以随取
我下面有个搭好的架子 ,新手可以下下来看看
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值