title: Using a custom interceptor in spring-boot, the @Value default is taking precedence over my configured value
body: <p>I am in the trenches of writing my first spring-boot app, so I believe I have a configuration issue somewhere that is causing my error.</p>
  
  <p>I have a class, "MyInterceptor", and it is annotated with "@Component" and extending HandlerInterceptorAdapter.</p>
  
  <pre><code>@Component
  public class MyInterceptor extends HandlerInterceptorAdapter { ... }
  </code></pre>
  
  <p>And I have a configuration class "WebConfiguration" that is annotated with "@Configuration" (and is NOT annotated with "@EnableWebMvc").</p>
  
  <p>I declare/inject my interceptor class in WebConfiguration like so:</p>
  
  <pre><code>@Resource
  private MyInterceptor myInterceptor;
  </code></pre>
  
  <p>and then specify this class as an interceptor like so:</p>
  
  <pre><code>@Override
  public void addInterceptors(InterceptorRegistry registry) {
      registry.addInterceptor(myInterceptor);
  }
  </code></pre>
  
  <p>In MyInterceptor, I have a property declared for which I want to inject a value. I have it declared, with a default, like so:</p>
  
  <pre><code>@Value("${my.interceptor.property:default_value}")
  private String myInterceptorProperty;
  </code></pre>
  
  <p>When I have the "default_value" declared in the @Value annotation as I do above, then that value is always used. The value declared in my application-dev.yml file is ignored.</p>
  
  <p>When I remove the default value, then the value in my application-dev.yml is used.</p>
  
  <p>It is my suspicion that the default value from the @Value annotation is being loaded AFTER the configured value and overriding it for some reason. But I can't figure out why or how to stop it.</p>
  
  <p>Other services in my app that are using @Value annotations, but that are NOT declared/injected in my WebConfiguration, are not exhibiting the same behavior.</p>
  
  <p>I tried adding my interceptor like this instead:</p>
  
  <pre><code>@Bean
  public MyInterceptor getMyInterceptor() {
      return new MyInterceptor();
  }
  </code></pre>
  
  <p>and then changed this:</p>
  
  <pre><code>@Override
  public void addInterceptors(InterceptorRegistry registry) {
      registry.addInterceptor(getMyInterceptor());
  }
  </code></pre>
  
  <p>But when I did this, then the configuration values in the application-dev.yml were never picked up regardless of whether or not I had a default value declared. </p>
  
  <p>I do understand why the @Resource annotated injection is making my configured properties available, and why the direct constructor call in the Config class is not. But is using the @Resource annotation the wrong way to do it? Why isn't my default being overridden?</p>
  
  <p>How should I be injecting configuration values into my interceptors and other classes that are similarly declared in my Config class?</p>