【问题标题】:Enable/ Disable different sets of Controllers in based on mode specified at startup Spring MVC根据启动时指定的模式启用/禁用不同的控制器集 Spring MVC
【发布时间】:2015-08-25 08:34:07
【问题描述】:

在开始我的 Spring MVC 战争时,我需要指定模式。 根据模式,它应该启动不同的控制器集。 是否可以通过指定模式/适用的控制器来做同样的事情 启动时?

一个类似的问题Spring MVC web application - enabling / disabling controller from property 只谈论测试,但我需要有各种组合并默认启动所有控制器。

【问题讨论】:

    标签: spring spring-mvc tomcat model-view-controller web


    【解决方案1】:

    Spring 通常有一个profile 机制,可以让你在不同的环境中注册不同的bean

    当您根据文档引导它时,区分控制器就像在类级别上注释它们一样简单,例如@Profile("mode1")@Profile("mode2")

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-09
      • 1970-01-01
      • 2011-07-31
      • 2021-07-19
      • 2019-04-22
      • 1970-01-01
      • 2021-11-27
      • 2013-12-30
      相关资源
      最近更新 更多