我有一个A类,它包含以下内容
class A
{
private HashSet<Long> at = new HashSet<Long>();
and it has a constructor like this
A()
{
//set is being initialsised here
this.at.add(new Long(44));
this.at.add(new Long(34));
this.at.add(new Long(54));
this.at.add(new Long(55));
}现在,下面是为它定义的spring xml bean…
<bean id="aa" class="com.abc.A">
<property name="readPermissionGroup">
<set>
<value>03</value>
<value>13</value>
<value>54</value>
<value>55</value>
</set>
</property>
</bean>现在,请告诉我如何将上述bean aa添加到bb中,因为bean bb包含A类的完整定义
发布于 2013-09-12 16:15:31
您可以使用@Anotation注入bean A。在类A中使用@Bean注释。@Bean注释将创建bean A。
class B {
@Autowired
private A beanA;
// setter and getter
}这是你的A班
@Bean
class A
{
private HashSet<Long> at = new HashSet<Long>();
A()
{
//set is being initialsised here
this.at.add(new Long(44));
this.at.add(new Long(34));
this.at.add(new Long(54));
this.at.add(new Long(55));
}https://stackoverflow.com/questions/18756491
复制相似问题