Spring beans.xml: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 11: Line 11:
         http://www.springframework.org/schema/beans/spring-beans.xsd">
         http://www.springframework.org/schema/beans/spring-beans.xsd">


     <bean name="blue" class="playground.spring.ioc.Blue">
    <bean name="red" class="playground.Red">
         <constructor-arg value = "something" />
        <constructor-arg value = "strong" />
    </bean>
 
     <bean name="blue" class="playground.Blue">
         <constructor-arg value = "pale" />
         <constructor-arg ref = "red" />
         <constructor-arg ref = "red" />
     </bean>
     </bean>


     <bean name="red" class="playground.spring.ioc.Red">
     <bean name="green" class="playground.Green">
         <constructor-arg value = "something else" />
         <constructor-arg value = "transparent" />
        <property name = "red" ref = "red" />
     </bean>
     </bean>
    <context:annotation-config/>
    <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>