title: Default value for profiles in Spring Boot
body: <p>I have multiple profiles and there are lots of attributes(which will grow), I don't want to set each attribute every time in a different profile.</p>
  
  <p>I have an <em>application.yml</em> file like this:</p>
  
  <pre><code>  freemarker:
      template-loader-path: classpath:/templates
  
    datasource:
      username: postgres
      password: mypass
      driver-class-name: org.postgresql.Driver
  
    jpa:
      show-sql: true
      properties:
        hibernate:
          jdbc:
            lob:
              non_contextual_creation: true
          dialect: org.hibernate.dialect.PostgreSQLDialect
      hibernate:
        ddl-auto: create
  
    security:
      secret: "jwt_secret_key_it_is_a_random_key_229"
      loginTokenExpiration: 86400
      confirmUserTokenExpiration: 86400
      devTokenExpiration: 157680000
      tokenPrefix: "Bearer"
      headerString: "Authorization"
      signUpUrl: "/token/login"
  
  mysite:
    apiTosUrl: "https://example.com/api-tos"
    fromEmail: "alert@example.com"
    firstFreeCredits: 10
  
  junction:
    port: 9080
    hasBasicAuth: false
  
  ---
  
  spring:
    profiles:
      active: dev
  
  ---
  
  spring:
    profiles: stage
  
    jpa:
      show-sql: true
      hibernate:
        ddl-auto: update
  
  chargeBee:
    site: "example.chargebee.com"
    apiKey: "mykey"
  
  ---
  
  spring:
    profiles: prod
  
    datasource:
      url: jdbc:postgresql://localhost/myproddb
  
    jpa:
      show-sql: false
      hibernate:
        ddl-auto: update
  
  chargeBee:
    site: "example.chargebee.com"
    apiKey: "myapikey"
  </code></pre>
  
  <p>Most of the settings are common between profiles, and which are not common, I have re-defined it in the corresponding section of the profile.
  I am assuming that the first section in this YAML document fills the properties with default values and the corresponding sections overwrite it.</p>
  
  <p>Is this approach correct? If not then how to have an inheritance of properties values such that I define the common value once and for the rest of the profiles, I only need to define the different values?</p>