java - Can I use spring to achieve this following goal? -


Bean A depends on the other bean B (the bean bean is the property of A).

I want that Bean B. is an object in some time and sometimes empty.

The simplest answer is the reference of Spring 2.x XML (and it will work in 3.x) In:

  & lt; Bean id = "A" square = "my.bean.A" & gt; & Lt; Property Name = "Property B" & gt; & Lt; Ref local = "b" /> & Lt; / Property & gt; & Lt; / Bean & gt; & Lt; Bean id = "b" square = "my.bean.b" />   

You can do your own building on it to expand 'B' so that it can have its own property:

  & lt; Bean id = "b" class = "my.bean.b" & gt; & Lt; Property Name = "property_C" & gt; & Lt; Ref local = "c" /> & Lt; / Property & gt; & Lt; / Bean & gt;   

You can change the B tap in relation to X to make the XML so that you can convert B to A

  & lt; Bean id = "A" square = "my.bean.A" />    

Comments