Issue

  • In order to separate the development environment, we divided the environment into three types: development, stage, and prod.
  • Also, I separated the yaml files under the package name env and config to separate them according to the purpose.
  • Below is an example of that
src
 |
 main
    |__  java
    |__  resources
               |___ application.yml
               |___ env
               |        |___ application-develop.yml
               |        |___ application-prod.yml
               |        |___ application-stage.yml
               |___ config
                          |___ application-youtube.yml
                          |___ application-jwt.yml
                          |___ application-oauth.yml
  • Also, below is the structure of the develop, prod, and stage yaml files.
spring:
    mvc:
    pathmatch:
      matching-strategy: ant_path_matcher
  profiles:
    include:
      - youtube
      - oauth-prod
      - jwt
      - redis
      active: youtube, oauth-prod, jwt, redis

      config:
        name: application-prod,application-youtube,application-oauth-prod,application-jwt,application-redis
        location: classpath:/env/application-prod.yml,classpath:/config/application-youtube.yml,classpath:/config/application-oauth-prod.yml,classpath:/config/application-jwt.yml,classpath:/config/application-redis.yml


  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql://127.0.0.1:5432/whatsong
    maximum-pool-size: '4'
    username: root
    password: root1234
  ######################################################################
  # JPA Settings
  ######################################################################
  jpa:
    hibernate:
      ddl-auto: update
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
    show-sql: true
    format_sql: true
    use_sql_comments: true
# application.yml
spring:
 profiles:
   active : /env/develop

Question

  • Why doesn't the YAML file work when it has the same structure as above?
  • To ask you a more detailed question, is 'ContextLoader' unable to find the yaml file even though it explicitly declared the path?
  • What should I do if I want to save it separately?
  • Is it a good structure to explicitly separate yaml files and multiple settings yaml files according to the environment?

Comment From: bclozel

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.