Java: is it useful to define beans in XML?

In the project I'm working on that uses Spring, I see something that really scares my mind. Apparently, there are unit tests that require beans, and those beans are created from XML files containing things like:

<bean class="...ListDTO">
 <constructor-arg>
  <map>
   <entry key="use1key">
    <value>use1value</value>
   </entry>
   <entry key="use2key">
    <value>use2value</value>
   </entry>
  </map>
 </constructor-arg>
 <constructor-arg>
  <map>
   <entry key="nature1key">
    <value>nature1value</value>
   </entry>
   <entry key="nature2key">
    <value>nature2value</value>
   </entry>
  </map>
 </constructor-arg>
 <constructor-arg>
  <value>false</value>
 </constructor-arg>
</bean>

What happened? The constructor of the class ... ListDTO has changed, and therefore the bean, apparently, can no longer be created from this (very detailed IMHO) XML.

Can someone explain to me why it is good practice (right?) To put such a thing in XML instead of Java code? If it were in Java code as soon as ... the ListDTO changed, the unit test would refuse to compile (even if the part of the unit test instruction that the bean was not executed [for whatever reason]).

: "beans XML" , , ., , ?

, IDE , : ? (*)

+5
3

, , (, , ) XML, .

bean . -, , , , , .

+6

: "beans XML" , , , , ?

Spring Spring Eclipse Spring ( ).

+1

All Articles