title: Spring Framework PropertySource based on Profile
body: <p>I have a Spring Boot multi-module maven project. I want my library module to handle its own properties.</p>
  
  <p>So, in the library module:</p>
  
  <pre><code>src/java/resources/module-name/application.properties
  src/java/resources/module-name/application-dev.properties
  src/java/resources/module-name/application-prod.properties
  </code></pre>
  
  <p>I have a <code>@Configuration</code> class in that module with:</p>
  
  <pre><code>@PropertySource("classpath://module-name/application-dev.properties")
  </code></pre>
  
  <p>Obviously, this will only load the <code>dev</code> properties.</p>
  
  <p>2 Questions:</p>
  
  <p>1) How do I factor in <code>@Profile</code> in here so I don't have to create multiple configuration classes, each with its own <code>@Profile</code>. Is there a way to combine the annotations or parameterize them with something like <code>application-${spring.active.profile}.properties</code>?</p>
  
  <p>2) How do I achieve the same behavior vis-a-vis <code>application.properties</code> file as I would have out of the box if these files were in the root of the classpath and picked up automatically by Spring? In other words, I'd like to place all the common properties into <code>application.properties</code> file and only the profile specific ones into <code>application-dev.properties</code> or <code>application-prod.properties</code> ones.</p>