title: Multiple Constructors with Different Parameters Springs
body: <pre><code>public class DisplayMessage {
  String Message;
  private String Message1;
  private String Message2;
  public DisplayMessage(String Message, String Message1) {
      this.Message=Message;
      this.Message1=Message1;
  }
  public DisplayMessage(String Message2){
      this.Message2=Message2;
  }
  public void display(){
      System.out.println(Message);
      System.out.println(Message1);
      System.out.println(Message2);
  }
  }
  </code></pre>
  
  <p>In above code Im injecting using 2 constructors with different parameters. I inserted values as below in xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context" 
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
          &lt;bean id="displayMessage" class="org.demo.DisplayMessage"&gt;
              &lt;constructor-arg value="Hi Welcome To Springs"&gt;&lt;/constructor-arg&gt;
              &lt;constructor-arg value="Hello"&gt;&lt;/constructor-arg&gt;
              &lt;constructor-arg value="I am Second"&gt;&lt;/constructor-arg&gt;
          &lt;/bean&gt;
   &lt;/beans&gt; 
  </code></pre>
  
  <p>When im using it using ClientApp Im getting lots of errors as</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'displayMessage' defined in class path resource [springbeans.xml]: 3 constructor arguments specified but no matching constructor found in bean 'displayMessage' (hint: specify index and/or type arguments for simple parameters to avoid type ambiguities)
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:181)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:835)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
      at org.demo.ClientApp.main(ClientApp.java:9)
  </code></pre>