title: Autowire working in unit test but not in main java class
body: <p>I've a domain class that I want to auto-populate from external config. Here is my domain class:</p>
  
  <pre><code>@Data
  @Configuration
  @PropertySource("classpath:application.properties")
  public class StudioVo {
  
     @Value("${studio.code}")
     private code;
  
      @Bean
      public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
          return new PropertySourcesPlaceholderConfigurer();
      }
  }
  </code></pre>
  
  <p>Here is my context xml:</p>
  
  <pre><code>&lt;bean class="org.springframework.batch.core.scope.StepScope" /&gt;
  &lt;bean id="ItemReader" class="com.sdm.studio.reader.StudioReader" scope="step"&gt;
       &lt;property name="studioVo" ref="StudioVo" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="StudioConfigVo" class="com.sdm.studio.domain.StudioVo" /&gt;
  
  &lt;/bean&gt;
  </code></pre>
  
  <p>Here is the class where I want to use the vo:</p>
  
  <pre><code>@Slf4j
  @Data
  public class StudioReader implements ItemReader&lt;List&lt;Studio&gt;&gt; {
  
     private StudioVo studioVo;
  
     public List&lt;Studio&gt; read() throws Exception {
  
        System.out.println("getCode: " + studioVo.getCode()); //code is null here
  
        return null;
     }
  
  }
  </code></pre>
  
  <p>However when I run it via unit test by autowiring, it runs fine. Like this:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  public class StudioTest {
  
     @Autowired
     private StudioVo studioVo;
  
      @Test
      public void testAutoPopulationOfStudio(){
        System.out.println("getCode: "+ studioVo.getCode()); // works!
        // Assert.assertTrue(studioVo.getCode().equals("102"));
      }
  }
  </code></pre>
  
  <p>Not sure what's going on here - I'm working with an old Spring Batch application wrapped in Spring Boot (so there is a mix of XML based and Java based config - and may be that is the cause of this issue). What am I missing?</p>