Can I activate profile in @PropertySource file in Spring Boot?
<p>I would like to activate a profile from my property file within application. Eventually I want to activate profile dynamically but I would like to start with static</p>
<p>My application</p>
<pre><code>@SpringBootApplication @PropertySource(&quot;classpath:/my.properties&quot;)
public class Application {

  public static void main(String[] args) {
      SpringApplication.run(Application.class, args);
  }

  @Component public static class MyBean {
    @Autowired public void display(@Value(&quot;${abc}&quot;) String abc) {
        System.out.println(&quot;Post:&quot;+ abc);
    }
</code></pre>
<p>my.properties:</p>
<pre><code>spring.profiles.active=STAT
abc=ABC
</code></pre>
<p>My output is a proof that my.properties are read, but profile is ignored</p>
<blockquote>
<p>No active profile set, falling back to default profiles: default</p>
<p>Display:ABC</p>
</blockquote>
<p>Maybe I should explain what I want to achieve. My pre-Spring Boot application behaviour depends on environment, for example if <code>$ENV=DEV</code> development config is used. I want migrate to Spring boot and put config to profile, but I would like to keep environments unchanged.
I want implement that</p>
<p><code>if $ENV=DEV then profile DEV is selected</code></p>
<p>My idea is add <code>my.properties</code> with <code>spring.profiles.active=$ENV</code> but it does not work</p>