Spring注释配置看起来像开销

时间:2011-02-24 13:17:03

标签: spring configuration annotations overhead

我刚刚面对,为了使用Spring Security的特定注释,我应该在我的配置中明确地允许它们(applicationContext.xml)
例如:

<sec:global-method-security secured-annotations="enabled" />
<sec:global-method-security jsr250-annotations="enabled" />
...

您在 的方法中看到哪些优势明确声明我们的框架化应用程序中允许使用哪些注释

看起来过度配置,不是吗?

1 个答案:

答案 0 :(得分:2)

一个可能的好处是,它允许Spring Security在类路径中不存在所需的注释时抛出异常(尽管它主要是关于JSR-250注释,因为其他注释是Spring Security本身的一部分)。

否则Spring Security将不得不默默地忽略注释的缺失,这可能会导致令人惊讶的行为。