title: Spring value injection unable to get value from properties
body: <p>I've got a class like this:</p>
  
  <pre><code>@Component
  public class FaultsConfiguration {
      private int interval;
  
      @Autowired
      public FaultsConfiguration(@Value("${faults.interval}") int interval) {
          this.interval = interval;
      }
  }
  </code></pre>
  
  <p>In application.properties I have this:</p>
  
  <pre><code>faults.interval=130
  </code></pre>
  
  <p>I think the bean should get the value 130 injected into it. Instead when the bean is initialized I get this error:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Could not resolve placeholder 'faults.interval' in value "${faults.interval}"
      at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)
      at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
      at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(PropertyPlaceholderConfigurer.java:258)
      at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:831)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1086)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
      at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
      at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
      at com.telensa.puma.etl.core.CoreApplication.main(CoreApplication.java:26)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
  </code></pre>
  
  <p>I've tried every variation on this I can find. I've tried alternative syntax like this:</p>
  
  <pre><code>@Value("${classpath:faults.interval}"
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code> @Value("#{faults.interval}"
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>"#{new Integer.parseInt('${faults.interval}')}"
  </code></pre>
  
  <p>and it all fails in a similar way.</p>
  
  <p>I have managed to get the property injected by using <code>@ConfigurationProperties</code> instead without any change to application.properties, like this (using Lombok):</p>
  
  <pre><code>@Service
  @ConfigurationProperties(prefix="faults")
  @Data
  @NoArgsConstructor
  public class FaultsConfiguration {
      private int interval;
  }
  </code></pre>
  
  <p>So clearly Spring is happy reading properties from application.properties.</p>
  
  <p>So why doesn't it work when I try and use value injection?</p>