-
Notifications
You must be signed in to change notification settings - Fork 41.2k
New profile is making structure rigid than configurable #24720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not sure I've totally understood your setup, if you have an example project that I can clone it might help me. I think you're saying that you have no One possible idea that you could look into is using the new spring.config.import=optional:classpath:applicationthisenv.properties This will import What do you do in your dev/staging/production environments? Do those get run with a specific profile active when they're started? Also, do you have |
I am attaching a sample project with README which will help you understand.
Exactly... Tracking something that changes with each environment is not feasible and will only create problems. This
I guess I had seen that somewhere, but still can't figure out how to include properties from different configurations. This situation is exactly like as you had seen in #24172 except for no tracking for application.properties.
Yes you are right. We have lot of hardwares :D [legacy style] and no cloud like setup to start from env.
No profile engineering with code, its all plain properties loading their required properties. We never felt any need to use code for this purpose. |
Thanks for the example, it helped a lot to clarify things. I think it should be possible to use You're main spring.profiles.active=local_john You'd then have a spring.config.import=./common.properties,./security.properties
application.conf.env_type=application-local.properties This will import This should give you the same result as your previous solution. If you wanted to (since you're not using Please let me know if that solution works for you. |
This looks promising I was not able to conclude that this syntax |
The Use case
This problem is more clear with an example use case:
Say I have following environments
Production
server visible to worldStaging
server visible to clientsDev
server visible to developersLocal
servers specific to individual developers say around 30 developers.The project is using
Git
version control. To deploy or to load a project the developer had to do following thingsIt was easier to do because
application.properties
was git ignored and runninggradle bootstrap <env_name>
generated inside itspring.profiles.active=<env_name>
. If provided <env_name> didn't exist a new profile with nameapplication-local_<env_name>.properties
was created from the templateapplication-local.properties
. The developer was free to choose from a set of properties for their specific needs. Thus building a configuration was as easy as writing code usingspring.profiles.include
.What changed
The new profile processing has put a new set of restrictions which is unable to answer a very simple problem i.e. given a constraint, a feature and a requirement like
production
,staging
anddev
should be tracked lets say themmajor configurations
.Lets try to address this problem
Trial 1:
Use profile groups by putting all major configurations in
application.yml
. Let user specify active profile and its configuration.Trial 2:
Add default
spring.profiles.active=this_env
inapplication.yml
and make it mandatory for user to create this file and add their customization there.application.yml
and has to copy whole thing again in their configuration. BecauseThe spring.profile.group property cannot be used in profile-specific documents.
activate.on-profile
then developers will be forced to use a set of rules.Trial 3:
Make
application.yml.example
with all contents and let developer copy and override it. Which is quit rough work.I am unable to find a proper solution to this problem, but for more understanding I am explaining my current set up so someone can guide how to address the problem if I am missing something .
Project files
.gitignore
hasapplication.properties.example
hasapplication-common.properties
has things likeapplication-common_pg.properties
hasapplication-security.properties.example
has passwords and others have their own data source urls. For exampleapplication-prod.properties
has at topThis is very difficult to migrate to the new structure I can't think of an idea without breaking one or two things.
The text was updated successfully, but these errors were encountered: