title: Null pointer exception for autowired class method
body: <p>I am new to Apache Camel and trying to build an api. It has three classes.</p>
  <p>Class A - this  is for reading application.properties file as below</p>
  <pre><code>@Configuration
  @ConfigurationProperties(prefix=&quot;api&quot;)
  public class A{
  
  private String username;
  
  public String getUsername(){
      return username
  }
  </code></pre>
  <p>Class B - Apache Camel Route.</p>
  <p>Class C - Bean class where class A is autowired.</p>
  <pre class="lang-java prettyprint-override"><code>@Component
  public class b extends RouteBuilder{
      @Autowired
      ClassC customC;
  
      public void configure{
          from(&quot;direct:start&quot;)
              .bean(customC)
              .to(&quot;log:first-timer&quot;)
      }
  }
  
  @Component
  class C{
      @Autowired
      ClassA config;
  
      String username=config.getUsername();
  }
  </code></pre>
  <p>Whenever IDE executes the api, it throws Null pointer exception in the line  <code>String username=config.getUsername();</code> .I have verified that spring boot is able to load application.properties.</p>
  <p>I am not sure why calling method of autowired class is throwing null pointer exception.</p>