首页>代码>Spring生命周期@PostConstruct和@PreDestroy的使用实例>/spring-lifecycle-postcontruct-predestroy-example/src/main/java/com/memorynotfound/spring/core/lifecycle/Monitor.java
package com.memorynotfound.spring.core.lifecycle;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

public class Monitor {

    private int timeout;

    public Monitor(int timeout) {
        this.timeout = timeout;
    }

    @PostConstruct
    public void init() throws Exception {
        System.out.println("- - - initializing monitor bean using @PostConstruct");
        System.out.println("@PostConstruct timeout: " + timeout);
    }

    @PreDestroy
    public void destroy() throws Exception {
        System.out.println("- - - destroying monitor bean using @PreDestroy");
    }
}
最近下载更多
最近浏览更多
444105047  LV6 2023年7月28日
kwm2921944  LV10 2021年6月16日
shiziliang  LV1 2021年6月14日
sherlockkkkkk  LV1 2021年6月11日
1304457666 2021年6月6日
暂无贡献等级
JavaLiuBing  LV3 2021年6月3日
骑着鱼儿过海的猫  LV1 2021年6月3日
xiao菜  LV2 2021年6月2日
月之氏族  LV23 2021年6月2日
avengo 2021年6月1日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友