当前位置: 代码迷 >> Java Web开发 >> spring有关问题请君解答
  详细解决方案

spring有关问题请君解答

热度:5765   发布时间:2013-02-25 21:14:08.0
spring问题请君解答
我想用注解的方式给spring中的一个名为UserDAOImpl类中的一个private int userId属性赋值,而我的beans.xml中是这样配置的<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
  <context:annotation-config/>
  <context:component-scan base-package="com.ufida"/>
   
   
  <aop:aspectj-autoproxy/>
   
   


</beans>
其他的受管bean我都可以使用@component和@resource来进行初始化,只有这个UserDAOImpl类中的原生类型的属性不知道怎么进行初始化!

------解决方案--------------------------------------------------------
<bean id="home" class="org.zmx.Home" >
<property name="userId">
<value>8888</value>
</property>
</bean>
楼主是这个意思?
------解决方案--------------------------------------------------------
试试 @AutoWired
  相关解决方案