简体   繁体   中英

How to Instantiate @configuration bean based on request parameters in java spring?

I have multiple configuration files in java spring. I need to instantiate it based on the request parameters. Is there any way to do it?

Thanks in advance!!

Sakthi

This is not possible, as Spring initializes the configuration before the service starts (or more accurate, when it starts) so when you get a request, it is too late - the configuration is already built.

You can, however, control it with spring profiles- either via env variable on the machine or arguments passed to the jvm when you run your app. This way you can control which spring profile to use and set the configurations per profile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM