title: spring boot read properties file from different maven module
body: <p>My maven project have three modules, <code>web</code>, <code>service</code>, <code>common</code></p>
  
  <p>Some parts of my project like this:</p>
  
  <pre><code>demo-parent:
    --web
      --src
        --main
          --java
            --Application.java
          --resources
            --application.properties
            --application-mysql.properties
     --service
     --common
       --src
         --main
           --java
             --ErrorCode.java
           --resources
             --application-errors.properties
  </code></pre>
  
  <p>In web moudle <code>Application.java</code>, I want to read contents from <code>common</code> moudle <code>application-errors.properties</code>. </p>
  
  <p>Here is my <code>ErrorCode.java</code> in <code>common</code>:</p>
  
  <pre><code>@Configuration
  @EnableAutoConfiguration
  @EnableConfigurationProperties
  @ConfigurationProperties(locations = "classpath:application-errors.properties")
  public class ErrorCode {
      private int code;
      private String message;
  
      public int getCode() {
          return code;
      }
  
      public void setCode(int code) {
          this.code = code;
      }
  
      public String getMessage() {
          return message;
      }
  
      public void setMessage(String message) {
          this.message = message;
      }
  }
  </code></pre>
  
  <p>Because I want to use this <code>application-errors.properties</code> from <code>web</code> module, So in <code>web</code> moudle, in <code>Application.java</code>:</p>
  
  <pre><code>@SpringBootApplication
  @PropertySources({
      @PropertySource("application-mysql.properties"),
      @PropertySource("application-errors.properties")
  })
  @EnableConfigurationProperties({ErrorCode.class})
  public class Application extends SpringBootServletInitializer {
  
      public static void main(String[] args) {
          SpringApplication application = new SpringApplication(Application.class);
          application.run(args);
      }
  }
  </code></pre>
  
  <p>Now, I add <code>EnableConfigurationProperties</code> to <code>Application.java</code> which contains <code>main</code> method, and I can get key and value from <code>application-errors.properties</code> file, my question is :</p>
  
  <p>If I want to invoke appliction-errors.propertie in <strong>other module</strong> like service, and service <strong>do not have a main method</strong>, what should I do ?</p>
  
  <p>We can read properties file by using java <code>Properties</code> class, but I want to use <strong>spring way</strong>.</p>
  
  <p>Anything advice is welcome, thanks in advance.</p>