Spring setter match the return type of the getter Spring 命名规范问题

来源:互联网 发布:公司一级域名是什么 编辑:程序博客网 时间:2024/04/29 13:51

因为Spring要求注入的成员变量要按照Sun的命名规范,所以,注入变量名必须首字母小写,而且在注入变量时,最好与java的类名相似。

在使用依赖的类中,要有get 与set

否则会出现错误:

   Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userDAO' of bean class [com.uisftech.manager.action.UserAction]: Bean property 'userDAO' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

 

因此在文件bean.xml中的变量一定要规范,

我改正后的配置是:

<bean id="userDao" class="com.uisftech.manager.user.dao.UserDao"  scope="prototype"/>
 <bean id="userServiceImpl" class="com.uisftech.manager.user.service.impl.UserServiceImpl"  scope="prototype">
  <property name="userDao">
   <ref bean="userDao" />
  </property>
 </bean>  

原创粉丝点击