@PostConstruct & Checked exceptions

前端 未结 3 1807
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-09 14:50

In the @PostConstruct doc it says about the annotated methods:

\"The method MUST NOT throw a checked exception.\"

How would one deal with e.g. an I

3条回答
  •  情歌与酒
    2020-12-09 15:37

    Yes, wrap it in a runtime exception. Preferebly something more concrete like IllegalStateException.

    Note that if the init method fails, normally the application won't start.

提交回复
热议问题