Spring beans.xml: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "<syntaxhighlight lang='xml'> <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSche...")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Internal=
* [[Spring_Dependency_Injection_and_Inversion_of_Control_Container_Concepts#Spring_beans.xml|Spring Dependency Injection and Inversion of Control Container Concepts]]
=Example=
<syntaxhighlight lang='xml'>
<syntaxhighlight lang='xml'>
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress SpringFacetInspection -->
<beans xmlns="http://www.springframework.org/schema/beans"
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans.xsd">
        http://www.springframework.org/schema/beans/spring-beans.xsd">
 
    <bean name="red" class="playground.Red">
        <constructor-arg value = "strong" />
    </bean>
 
    <bean name="blue" class="playground.Blue">
        <constructor-arg value = "pale" />
        <constructor-arg ref = "red" />
    </bean>


  <bean id="..." class="...">
    <bean name="green" class="playground.Green">
    <!-- collaborators and configuration for this bean go here -->
        <constructor-arg value = "transparent" />
  </bean>
        <property name = "red" ref = "red" />
    </bean>


  <bean id="..." class="...">
     <context:annotation-config/>
     <!-- collaborators and configuration for this bean go here -->
  </bean>


  <!-- more bean definitions go here -->
    <context:component-scan base-package="playground"/>


</beans>
</beans>
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 19:02, 6 November 2018

Internal

Example

<?xml version="1.0" encoding="UTF-8"?>
<!--suppress SpringFacetInspection -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean name="red" class="playground.Red">
        <constructor-arg value = "strong" />
    </bean>

    <bean name="blue" class="playground.Blue">
        <constructor-arg value = "pale" />
        <constructor-arg ref = "red" />
    </bean>

    <bean name="green" class="playground.Green">
        <constructor-arg value = "transparent" />
        <property name = "red" ref = "red" />
    </bean>

    <context:annotation-config/>

    <context:component-scan base-package="playground"/>

</beans>