Graceful handling of exception thrown while creating beans

后端 未结 1 1919
温柔的废话
温柔的废话 2020-12-22 00:03

I want my Spring MVC web app to gracefully handle a particular type of exception thrown while creating the beans.

The construction of one of my beans reads configura

1条回答
  •  醉梦人生
    2020-12-22 00:43

    I worked around this difficulty by introducing a level of indirection. My bean is really just a handle. If the configuration file is bad, the bean catches the exception, logs a message, and notes that reading failed. Accessing the bean later then throws a suitable exception.

    0 讨论(0)
提交回复
热议问题