title: Autowiring in Spring with annotations
body: <p>In my simple Spring project I have a class-bean named Property :</p>
  
  <pre><code>@Component
  public class Property implements DisposableBean,InitializingBean{
  
      private int square_area;
      private int floor_count;
  
      @Autowired
      @Qualifier("myLocation")
      private Location location;
  
      public Property() {
          super();
      }
  
      @Bean
      @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
      public Property prop(){
          return new Property(100,3);
      }
  
      public Property(int square_area, int floor_count, Location location) {
          this.square_area = square_area;
          this.floor_count = floor_count;
          this.location = location;
      }
  
      public Property(int square_area, int floor_count) {
          this.square_area = square_area;
          this.floor_count = floor_count;
          this.location = location;
      }
  
  
      public void afterPropertiesSet() throws Exception {
          // TODO Auto-generated method stub
  
      }
  
      public void destroy() throws Exception {
          // TODO Auto-generated method stub
  
      }
  
      public int getSquare_area() {
          return square_area;
      }
  
      public void setSquare_area(int square_area) {
          this.square_area = square_area;
      }
  
      public int getFloor_count() {
          return floor_count;
      }
  
      public void setFloor_count(int floor_count) {
          this.floor_count = floor_count;
      }
  
  
      public Location getLocation() {
          return location;
      }
  
  
      public void setLocation(Location location) {
          this.location = location;
      }
  
      @Override
      public String toString() {
          return "Property [square_area=" + square_area + ", floor_count=" + floor_count + ", location=" + location + "]";
      }
  
      public void gettingDusty(){
          System.out.println("Im getting dusty | " + this);
      }
  
  }
  </code></pre>
  
  <p>and I'm trying to autowire field "location".
  Location class looks like this :</p>
  
  <pre><code>@Component
  public class Location {
  
      private String country;
      private String region;
      private String settlement;
      private String street;
      private int house;
  
      @Bean("myLocation")
      @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
      public Location myLocation(){
          return new Location("US","California","Some peacefull town","Some peacefull street",1);
      }
  
      public Location(String country, String region, String settlement, String street, int house) {
          super();
          this.country = country;
          this.region = region;
          this.settlement = settlement;
          this.street = street;
          this.house = house;
      }
  
      @Override
      public String toString() {
          return "Location [country=" + country + ", region=" + region + ", settlement=" + settlement + ", street="
                  + street + ", house=" + house + "]";
      }
  }
  </code></pre>
  
  <p>And I'm getting org.springframework.beans.factory.UnsatisfiedDependencyException
  :</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'property': Unsatisfied dependency expressed through field 'location'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'location' defined in file [C:\Users\TheDanileron\spring_tests\spring_test4\target\classes\spring_tests\spring_test3\Location.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:581)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:367)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1340)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1249)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1098)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:330)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
      at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083)
      at spring_tests.spring_test3.App.main(App.java:25)
  Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'location' defined in file [C:\Users\TheDanileron\spring_tests\spring_test4\target\classes\spring_tests\spring_test3\Location.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723)
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1269)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1126)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
      at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1133)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1060)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:578)
      ... 18 more
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1501)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1099)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1060)
      at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:809)
      at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:715)
      ... 31 more
  </code></pre>
  
  <p>How can I autowire field "location" with a bean created by myLocation method in Location.class ?</p>