Configuration in code
Pros:
- Single point of truth as all properties are in one location which is easily accessed by everyone in your team. It's easier to compare different environments when all configurations are in one place.
- The version control system tracks all changes to environment properties. You can describe the reason for change in a commit message.
- You can validate the correctness of properties during the build process with automated tests and avoid starting your application with an invalid configuration.
Cons:
- Changing the configuration (even for a single environment) requires rebuild of the whole application.
- The version control system may be used to store sensitive authentication information, e.g. database passwords. Keeping such values even if encrypted form might be risky.
- If your organization limits access to production environment for regular developers and has a special operation team dedicated to this role, the development team probably won't have all required configuration details to put them in the code repository.
Configuration in environment
Pros:
- Changing configuration doesn't require additional application rebuild.
- Sensitive information aren't stored in the version control system.
- Runtime configuration update can be implemented.
Cons:
- Configuration must be verified when the application is started. Especially important if deployments are not automated and executed by someone outside of the development team.
- The history of configuration changes may not be as clear as using the version control system. The connection between code and configuration changes is lost.
- Reproduction of a bug might be impossible without knowing the exact configuration of the application when the problem occurred. Tracking external configuration changes is a more complex task.
Nothing is black and white, you can always use a compromise solution which mixes both approaches. One part of your configuration might be suitable to keep it with the source code, while another may be kept outside. As usual in programming it depends on your needs.