美文网首页
@PostConstruct和@PreConstruct注解

@PostConstruct和@PreConstruct注解

作者: AmeeLove | 来源:发表于2017-10-24 09:24 被阅读124次

    @PostConstruct说明

     被@PostConstruct修饰的方法会在服务器加载Servlet的时候运行,并且只会被服务器调用一次,类似于Serclet的inti()方法。被@PostConstruct修饰的方法会在构造函数之后,init()方法之前运行。
    

    @PreConstruct说明

     被@PreConstruct修饰的方法会在服务器卸载Servlet的时候运行,并且只会被服务器调用一次,类似于Servlet的destroy()方法。被@PreConstruct修饰的方法会在destroy()方法之后运行,在Servlet被彻底卸载之前。

    相关文章

      网友评论

          本文标题:@PostConstruct和@PreConstruct注解

          本文链接:https://www.haomeiwen.com/subject/kfctpxtx.html