0

I want to have my own configuration property: isRegistrationEnabled=false. I want to check it and change in my controllers. How to easily do this in spring?

donnme
  • 1
  • can you be helped by reading this question? https://stackoverflow.com/questions/3339736/set-system-property-with-spring-configuration-file – user1239299 Jun 02 '21 at 11:31

1 Answers1

0

If you want some variable to check AND change it then use simple variable. Configuration properties are values used to configure application on startup not to modify them in a runtime for example database password. Its only needed on startup and won't change in a runtime additionaly you can alter this without changing code providing flexibility.

  • Thank you. Variable is good idea if I want this property in one class. But I want access for it in 2 different controllers. How to solve this problem? – donnme Jun 01 '21 at 19:53
  • You can create a bean with this variable and inject it in those 2 controllers or use static variable. – Maciej Niedźwiedź Jun 01 '21 at 19:58