• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
龙飞腾
博客园    首页    新随笔    联系   管理    订阅  订阅
spring随手笔记3:销毁方法

1.

 1 public class HelloWorld {
 2     private String msg;
 3     public void setMsg(String msg) {
 4         this.msg = msg;
 5     }
 6     public String getMsg() {
 7         return msg;
 8     }
 9     public void detory(){
10         this.msg="";
11     }
12 }
<bean id="HelloWord" class="com.ltf.captha.serviceImpl.HelloWorld" destroy-method="destory">
        <property name="msg">
            <value>helloworld</value>
        </property>
    </bean>

2.  实现org.springframework.beans.factory.DisposableBean中的destory方法

public class HelloWorld implements DisposableBean{
    private String msg;
    public void setMsg(String msg) {
        this.msg = msg;
    }
    public String getMsg() {
        return msg;
    }
    public void destroy() throws Exception {
        this.msg="";
    }
    
}

 

posted on 2014-09-24 11:04  龙飞腾  阅读(139)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3