title: How to use Auto Wiring in spring for two beans?
body: <p>I am new to apply Auto Wiring for two beans.please check my code below</p>
  
  <p><strong>Color.java</strong></p>
  
  <pre><code>public class Color {
  
  private String baseColor;
  
  private String textureColor;
  
  public String getBaseColor() {
      return baseColor;
  }
  
  public void setBaseColor(String baseColor) {
      this.baseColor = baseColor;
  }
  
  public String getTextureColor() {
      return textureColor;
  }
  
  public void setTextureColor(String textureColor) {
      this.textureColor = textureColor;
  }
  
  @Override
  public String toString() {
      return baseColor + " base skin color and " + textureColor + " texture color." ;
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Behaviour.java</strong></p>
  
  <pre><code>public class Behaviour{
  
  private String behaviourType;
  
  
  
  public String getBehaviourType() {
      return behaviourType;
  }
  
  public void setBehaviourType(String behaviourType) {
      this.behaviourType = behaviourType;
  }
  
  
  }
  </code></pre>
  
  <p><strong>Cat .java</strong></p>
  
  <pre><code>public class Cat {
  
  private String name;
  
  private Color color;
      private Behaviour behaviour;
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public Color getColor() {
      return color;
  }
  
  public void setColor(Color color) {
      this.color= color;
  }
  public Color getBehaviour() {
      return behaviour;
  }
  
  public void setBehaviour(Behaviour behaviour) {
      this.behaviour= behaviour;
  }
  @Override
  public String toString() {
      return "The " + name + " has " + color.toString();
  
  }
  }
  </code></pre>
  
  <p><strong>applicationContext.xml</strong></p>
  
  <pre><code> &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
      xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:task="http://www.springframework.org/schema/task"
      xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd"&gt;
  
      &lt;bean id="color" class="com.javacodegeeks.snippets.enterprise.Color"&gt;
          &lt;property name="baseColor" value="white" /&gt;
          &lt;property name="textureColor" value="grey" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="cat" class="com.javacodegeeks.snippets.enterprise.Cat"&gt;
          &lt;property name="name" value="cat" /&gt;
          &lt;property name="color" ref="color" /&gt;
                 &lt;property name="behaviour" ref="behaviour" /&gt;
      &lt;/bean&gt;
            &lt;bean id="behaviour" class="com.javacodegeeks.snippets.enterprise.Behaviour"&gt;
          &lt;property name="behaviourType" value="Somebevhaviour" /&gt;
  
       &lt;/bean&gt;
     &lt;/beans&gt;
  </code></pre>
  
  <p>It's working fine but i want to apply dependency  by using Auto Wiring (byName) any one help for writing the applicationContext.xml file</p>