Enable/ Disable different sets of Controllers in based on mode specified at startup Spring MVC

138 Views Asked by At

While starting my Spring MVC war I need to specify the mode. Based on mode it should start different set of controllers. Is it possible to do the same by specifying mode/ applicable controllers while starting it?

A similar question Spring MVC web application - enabling / disabling controller from property only talks of test but I need to have various combinations and start all controllers as default.

1

There are 1 best solutions below

0
On BEST ANSWER

Spring in general has a profile mechanism that lets you register different beans in different environments

When you bootstrap it according to doc, distinguishing controllers is as simple as annotating them on a class level with e.g. @Profile("mode1") vs @Profile("mode2")