title: Could not resolve matching constructor.Ambiguity issue with Spring dependency injection
body: <p>I am getting the error "<code>Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)</code>" while executing my spring program. I am new to Spring core and trying to learn the framework. Below is the code:</p>
  
  <p>Student.java</p>
  
  <pre><code>package com.inject.test;
  
  public class Student {
  
      private String name;
      private String className;
      private Address address;
  
  
  
      public Address getAddress() {
          return address;
      }
      public void setAddress(Address address) {
          this.address = address;
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public String getClassName() {
          return className;
      }
      public void setClassName(String className) {
          this.className = className;
      }
  
  
  }
  </code></pre>
  
  <p>Address.java</p>
  
  <pre><code>package com.inject.test;
  
  public class Address {
  
      private String city;
      private String state;
  
  
  
  
      public String getCity() {
          return city;
      }
      public void setCity(String city) {
          this.city = city;
      }
      public String getState() {
          return state;
      }
      public void setState(String state) {
          this.state = state;
      }
  
  }
  </code></pre>
  
  <p>Test.java</p>
  
  <pre><code>package com.inject.test;
  
      import org.springframework.context.ApplicationContext; 
      import org.springframework.context.support.ClassPathXmlApplicationContext;
  
      public class Test {
  
          public static void main(String[] args) {
  
              @SuppressWarnings("resource")
              ApplicationContext context =  new ClassPathXmlApplicationContext("file:com/applicationContext.xml");
              Student student = (Student) context.getBean("student");
  
              System.out.println("Name: " + student.getName());
              System.out.println("Class: " + student.getClassName());
  
              Address studentAddress = student.getAddress();
  
  
              System.out.println("Student Address: ");
              System.out.println("City: " + studentAddress.getCity());
              System.out.println("State: " + studentAddress.getState());      
          }
  
      }
  </code></pre>
  
  <p>applicationContext.xml</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"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
     &lt;bean id="student" class="com.inject.test.Student"&gt;
         &lt;property name="name" value="Jai"/&gt;
         &lt;property name="className" value="MCA"/&gt;
         &lt;constructor-arg ref="address" type="java.lang.String"/&gt;
     &lt;/bean&gt;
  
      &lt;bean id="address" class="com.inject.test.Address"&gt;
         &lt;property name="city" value="Hyderabad"/&gt;
         &lt;property name="state" value="Telangana"/&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>What change should be made to resolve the constructor issue, please suggest. </p>