`
hooroger
  • 浏览: 12668 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Reason remind fro @ControllerAdvice @ExceptiionHandler does not work

阅读更多

Configured following lines in web.xml for servlet:               

                <init-param>

<param-name>detectAllHandlerExceptionResolvers</param-name>

<param-value>false</param-value>

</init-param>

 

===================================explain for the exception handler ====================

The <mvc:annotation-driven/> element implicitly registers a ExceptionHandlerExceptionResolverbean. This class has a initExceptionHandlerAdviceCache() method which scans beans in the context to find those whose class type is annotated with @ControllerAdvice.

It does this by first calling ControllerAdviceBean.findAnnotatedBeans(ApplicationContext). Internally, this method uses ApplicationContext#getBeanDefinitionNames(). The javadoc of this method states

Does not consider any hierarchy this factory may participate

To clarify what this means. When you declare a ContextLoaderListener in your deployment descriptor, it loads what we call a root or application ApplicationContext and makes it available in the ServletContext. When you then declare a DispatcherServlet, it creates its own servlet ApplicationContext and uses any ApplicationContext it finds in the ServletContext attributes loaded by the ContextLoaderListener as a parent to that context. The hierarchy looks like so

Root ApplicationContext // loaded by the ContextLoaderListener
            |
Servlet ApplicationContext // loaded by the DispatcherServlet

Every ApplicationContext has access to beans in parent contexts, but not the other way around.

The method above chooses not to use the beans in parent contexts and so only has access to beans in the current ApplicationContext (BeanFactory really).

As such, if your

<context:component-scan .../>

is declared in a root ApplicationContext as I'll assume from the name app-config, but the

<mvc:annotation-driven />

is declared in the servlet ApplicationContext, again assuming from mvc-config, then the ExceptionHandlerExceptionResolver looking for @ControllerAdvice beans will not find any. It is looking for beans in the servlet context but they aren't there, they are in the root context.

分享到:
评论

相关推荐

    Rocket.Chat.App-Remind

    用法:/ remind [我或@someone或#channel] [什么] [何时]例子触发以下提醒: /remind me to go out and take long walk in 10 minutes以用户身份发帖将向您发送确认消息,提示您已收到并安排了提醒。 rocket.cat: :...

    mattermost-remind:最重要的提醒斜线命令

    最重要的提醒 使用构建的/ remind斜杠命令/remind [@someone or ~channel] [what] [when]用法请参阅中的“的完整列表/remind help /remind list /remind version /remind [who] [what] [when] /remind [who] [what] ...

    Go-git-remind是一个命令行工具可以防止你忘记git-commit和git-push

    git-remind是一个命令行工具,可以防止你忘记git-commit和git-push

    OA办公系统数据库字典.pdf

    not null REMIND_DATE varchar(200) not null REMIND_TIME time not null 00:00:00 CONTENT text not null LAST_REMIND date not null 0000-00-00 SMS_REMIND char(1) not null 1 SMS2_REMIND varchar(2) not null ...

    Remind.rar

    C#做的定时关机,定时提醒,和简单农历日历 源代码

    mattermost-plugin-remind:最重要的插件,可为用户和频道设置提醒

    System Console -&gt; Experimental Features -&gt; Timezone = true用法/remind打开一个以安排提醒/remind help -显示帮助示例/remind list -显示/remind list /remind [who] [what] [when] /remind [who] [what] in [# ...

    Time_to_remind.rar_Time

    时间提醒系统(Time to remind the system)

    remind:将思维导图带到浏览器

    Remind是一个基于React的免费开放源代码思维导图编辑器。 在上尝试 地位 基本的编辑器功能已实现(撤消,重做,导航,拖动,CRUD主题,快捷方式支持) 支持基本定制 该项目正在积极开发中,请在查看 安装 npm i ...

    雪狐提醒簿(Remind Book)

    雪狐提醒薄 是一个简单、易用、功能强大的提醒管理软件。 支持多种循环提醒、公元1年到...软件名称: 雪狐提醒簿(Remind Book) 版 本: Ver3.22 使用环境: NT / Win2000 / XP / Srv2003 软件类型: 共享软件

    Remind:提醒一下,一个 todo 管理应用

    Remind 是一个使用客户端-服务器架构开发的“待办事项”管理器。 服务器是用 Jersey 开发的 Java Servlet,而客户端是使用 Cordova 的移动应用程序。 特征 服务器 登录 - 登录 添加、编辑和删除“待办事项” 检索...

    remind-me:一个Powercord插件,可让您设置提醒

    Powercord插件,可让您使用remind &lt;duration&gt; 命令设置提醒 安装 要安装此插件,请转到您的插件目录,并使用以下命令将其克隆。 git clone https://github.com/Killerjet101/remind-me.git 去做 在设定的时间重复...

    Remind warning.rar

    VS2019 VB代码与S7-200/300/400/1200/1500 PLC通讯,访问PLC地址,读取DB内容,并与特定字符比较,声音提醒

    系统工具-文件下载-闪电提醒(Flash Remind) 0.9.53.zip

    系统工具-文件下载-闪电提醒(Flash Remind) 0.9.53.zip

    chunxiao-remind.zip

    很有作用 提醒休息 提醒工作 提醒吃药 提醒喝水 提醒运动

    premise:将REMIND输出耦合到ecoinvent LCA数据库

    rmnd-lca设计为仅与IAM模型REMIND一起使用。 现在,随着它向IAM更加中立的方向发展,考虑了名称的更改。0.2.0中有什么新功能? 破译代码-&gt;新的工作流程(请查看):由于原始的ecoinvent数据库和清单仅加载一次,...

    git-remind:永远不要忘记git commit和push

    git-remind是一个命令行工具,可以防止您忘记git-commit和git-push。 产品特点 git-commit / git-push状态 git-remind检查您计算机中所有git存储库的状态,并显示状态是否存在未提交的文件和应提交到远程的预先提交...

    提醒分享按钮「Remind Share Button」-crx插件

    在一次点击中与您的提醒类共享链接。 通过与您的提醒课程共享资源,节省时间并将学习范围扩展到课堂之外。 支持语言:English

    Remind-开源

    该应用程序专为那些希望保留信息而又不想将大型应用程序用于此类基本任务的人而设计。

    slack-remind

    放松提醒 项目设置 npm install 编译和热重装以进行开发 npm run serve 编译并最小化生产 npm run build 整理和修复文件 npm run lint 自定义配置 请参阅。

    Numerical.Python.2nd.Edition

    theory of the covered topics are given in each chapter, to introduce notation and remind readers of the basic methods and algorithms. However, this book is not a self-consistent treatment of numerical...

Global site tag (gtag.js) - Google Analytics