title: Does Spring follow any naming convention for application configuration?
body: <p><strong>Issue :
  <strong>Configuration defined in application.properties is not overridden by environment variable</strong>.</strong></p>
  <p>I'm facing strange issue with spring configuration as configuration defined in <code>application.properties</code> is not overridden by environment variable when configuration is named in specific way. As mentioned in <a href="https://docs.spring.io/spring-boot/docs/1.2.2.RELEASE/reference/html/boot-features-external-config.html" rel="nofollow noreferrer">Externalized Configuration</a> OS environment variables takes precedence over <code>application.properties</code> but this doesn't happen when configuration is defined as <code>myExternal_url</code> but it works when configuration is defined as <code>my_external_url</code> (in sample code below, we need to change configuration to <code>my_external_url</code> in <code>ApplicationProperties.java</code> and <code>application.properties</code>)</p>
  <p>Sample Code -</p>
  <pre><code>@SpringBootApplication
  public class ConfigApplication implements ApplicationRunner {
  
    @Autowired private ApplicationProperties applicationProperties;
  
    public static void main(String[] args) {
      SpringApplication.run(ConfigApplication.class, args);
    }
  
    @Override
    public void run(ApplicationArguments arg0) {
      System.out.println(&quot;External URL = &quot; + applicationProperties.getMyExternalUrl());
    }
  }
  </code></pre>
  <p>Application Bean configuration -</p>
  <pre><code>@Configuration
  public class AppConfig {
  
    @Bean
    @ConfigurationProperties(prefix = &quot;&quot;)
    public ApplicationProperties applicationProperties() {
      return new ApplicationProperties();
    }
  }
  </code></pre>
  <p><code>ApplicationProperties</code> class -</p>
  <pre><code>public class ApplicationProperties {
  
    @Value(&quot;${myExternal_url}&quot;)
    private String myExternalUrl;
  
    public String getMyExternalUrl() {
      return this.myExternalUrl;
    }
  
    public void setMyExternalUrl(String myExternalUrl) {
      this.myExternalUrl = myExternalUrl;
    }
  }
  </code></pre>
  <p><code>application.properties</code>:</p>
  <pre><code>myExternal_url=external_url_env_application_properties
  </code></pre>
  <p>What could be reason for this ?</p>
  <p>EDIT - adding gradle
  Gradle configuration</p>
  <pre><code>plugins {
      id 'org.springframework.boot' version '2.4.0-M1'
      id 'io.spring.dependency-management' version '1.0.9.RELEASE'
      id 'java'
  }
  
  group = 'com.example'
  version = '0.0.1-SNAPSHOT'
  sourceCompatibility = '1.8'
  
  repositories {
      mavenCentral()
      maven { url 'https://repo.spring.io/milestone' }
  }
  
  dependencies {
      implementation 'org.springframework.boot:spring-boot-starter-web'
      testImplementation 'org.springframework.boot:spring-boot-starter-test'
      compileOnly 'org.projectlombok:lombok:1.18.6'
      annotationProcessor 'org.projectlombok:lombok:1.18.6'
  }
  
  test {
      useJUnitPlatform()
  }
  </code></pre>
  <p>EDIT 2</p>
  <p>Trace log shows that myExternal_url is resolved correctly from Environment variable. Then Spring tries to resolve autowired dependencies '<code>applicationProperties</code>' by calling <code>AutowiredAnnotationBeanPostProcessor</code> and then value is overridden by application.properties value (screen shot).</p>
  <pre><code>o.s.c.e.PropertySourcesPropertyResolver  : Found key 'myExternal_url' in PropertySource 'systemEnvironment' with value of type String
  o.s.c.e.PropertySourcesPropertyResolver  : Found key 'myExternal_url' in PropertySource 'environmentProperties' with value of type String
  </code></pre>
  <p><a href="https://i.stack.imgur.com/bJ9pH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bJ9pH.png" alt="Debug ApplicationProperties" /></a></p>