title: Spring-Boot multi module project load property-file
body: <p>I have a Spring-Boot-Application as a multimodule-Project in maven. The structure is as follows:</p>
  
  <pre><code>Parent-Project
  |--MainApplication
  |--Module1
  |--ModuleN
  </code></pre>
  
  <p>In the <code>MainApplication</code> project there is the <code>main()</code> method class annotated with <code>@SpringBootApplication</code> and so on. This project has, as always, an application.properties file which is loaded automatically. So I can access the values with the <code>@Value</code> annotation</p>
  
  <pre><code>@Value("${myapp.api-key}")
  private String apiKey;
  </code></pre>
  
  <p>Within my Module1 I want to use a properties file as well (called module1.properties), where the modules configuration is stored. This File will only be accessed and used in the module. But I cannot get it loaded. I tried it with <code>@Configuration</code> and <code>@PropertySource</code> but no luck.</p>
  
  <pre><code>@Configuration
  @PropertySource(value = "classpath:module1.properties")
  public class ConfigClass {
  </code></pre>
  
  <p>How can I load a properties file with Spring-Boot and access the values easily? Could not find a valid solution.</p>
  
  <p><strong>My Configuration</strong>  </p>
  
  <pre><code>@Configuration
  @PropertySource(value = "classpath:tmdb.properties")
  public class TMDbConfig {
  
      @Value("${moviedb.tmdb.api-key}")
      private String apiKey;
  
      public String getApiKey() {
          return apiKey;
      }
  
      @Bean
      public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
          return new PropertySourcesPlaceholderConfigurer();
      }
  }
  </code></pre>
  
  <p><strong>Calling the Config</strong></p>
  
  <pre><code>@Component
  public class TMDbWarper {
  
  @Autowired
  private TMDbConfig tmdbConfig;
  
  private TmdbApi tmdbApi;
  
  public TMDbWarper(){
      tmdbApi = new TmdbApi(tmdbConfig.getApiKey());
  }
  </code></pre>
  
  <p>I'm getting an NullPointerException in the constructor when I autowire the warper.</p>