title: Using PropertyOverrideConfigurer with Annotated Classes in Spring 3
body: <p><strong>Edit</strong>: Here is some explanation of why the accepted answer works for me, and possibly what could be a problem for others.</p>
  
  <p>In my foo-app-servlet.xml, i have this line:    </p>
  
  <pre><code>&lt;context:component-scan base-package="com.foo.app" /&gt;
  </code></pre>
  
  <p>When I used spring2 before, all my service beans came from applicationContext.xml, but now they are being brought in directly in the foo-app-servlet.xml.  On my project servlets have their own set of overrides, so I need to override in the servlet override file instead of the applicationContext override file.</p>
  
  <p>When overriding, if you haven't named your component then it does indeed use the lowercase version of it, so to override OrderService.foo, you do this:</p>
  
  <pre><code>orderService.foo=bar
  </code></pre>
  
  <p><strong>End Edit</strong></p>
  
  <p>I'm working an a project that was upgraded from spring 2.5 to spring 3 and thus has both xml and annotation based config.  We previously have used PropertyOverrideConfigurer to change properties in different environments to great success.  I'm now working on code that uses authorize.net and I need to make sure I don't send anything to them from the development environment.  </p>
  
  <p>In order to accomplish this I want to override my 'testMode' property with PropertyOverrideConfigurer.  This works great for beans that are configured via xml, but I can't figure out how to do it with annotation configured classes.  </p>
  
  <p>This is my override snippet from applicationContext.xml:</p>
  
  <pre><code>&lt;bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer"&gt;
      &lt;property name="location" value="file:${user.home}/override.properties" /&gt;
      &lt;property name="localOverride" value="true" /&gt;
      &lt;property name="ignoreResourceNotFound" value="true" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Here is the class with the property I want to override:</p>
  
  <pre><code>@Component
  public class OrderService {
      private static Log logger = LogFactory.getLog(OrderService.class);
  
      @Autowired @Qualifier("OrderDAO") private OrderDAO orderDao;
  
      @Autowired private SiteManager siteManager;
      String authorizenetProperties = "classpath:authorizenet.properties";
  
      private Boolean testMode = false;
  
      public Boolean getTestMode() {
          return testMode;
      }
  
      public void setTestMode(Boolean testMode) {
          this.testMode = testMode;
      }
  
  }
  </code></pre>
  
  <p>I've tried a few things that didn't work:</p>
  
  <pre><code>com.foo.services.OrderService.testMode=true
  OrderService.testMode=true
  </code></pre>
  
  <p>Is it possible to do what I want to do here?  Does spring 3 have a new preferred way of doing this?</p>