title: You cannot autowire so-called simple properties such as primitives, Strings, and Classes
body: <p>I'm new to Spring and looking for detail learning. I was reading about autowiring and read <code>You cannot autowire so-called simple properties such as primitives, Strings, and Classes (and arrays of such simple properties)</code> <a href="https://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-autowired-exceptions" rel="nofollow noreferrer">here</a>.</p>
  
  <p><strong>1)</strong> I didn't understand what does it mean by <code>Classes</code> here?</p>
  
  <p><strong>2)</strong> They said you can't autowire primities, but I tried for <code>Integer</code> wrapper classes, they are still not working, why? See the code below.</p>
  
  <p><strong>Beans:</strong></p>
  
  <pre><code>&lt;bean id="teacher" class="com.climesoft.webapp.model.Teacher"
          autowire="byName"&gt;
  &lt;/bean&gt;
  &lt;bean id="id" class="java.lang.Integer"&gt;
              &lt;constructor-arg value="20" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p><strong>Java Class Here:</strong></p>
  
  <pre><code>public class Teacher {
  
      private String name;
  //  private int id;
      private Integer id; // for autowiring
      private String phone;
      private Course course;
  
  
      public Course getCourse() {
          return course;
      }
  
      public void setCourse(Course course) {
          this.course = course;
      }
  
      public Teacher() {
          System.out.println("Calling Teacher No Param Constructor");
      }
  
      public Teacher(String name, Integer id, String phone) {
          this.name = name;
          this.id = id;
          this.phone = phone;
  
          System.out.println("Calling Teacher Param Constructor");
      }
  
      public String getName() {
          System.out.println("Calling Teacher getName");
          return name;
      }
      public void setName(String name) {
          System.out.println("Calling Teacher setName");
          this.name = name;
      }
      public Integer getId() {
          System.out.println("Calling Teacher getId");
          return id;
      }
      public void setId(Integer id) {
          System.out.println("Calling Teacher setId");
          this.id = id;
      }
      public String getPhone() {
          System.out.println("Calling Teacher getPhone");
          return phone;
      }
      public void setPhone(String phone) {
          System.out.println("Calling Teacher setPhone");
          this.phone = phone;
      }
  
      @Override
      public String toString() {
          return "Teacher [name=" + name + ", id=" + id + ", phone=" + phone + ", course=" + course + "]";
      }
  
  
  }
  </code></pre>