spring bean的生命周期
Posted 老邱2
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring bean的生命周期相关的知识,希望对你有一定的参考价值。
package com.huawei.entity;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class Test implements BeanNameAware,BeanFactoryAware,InitializingBean,ApplicationContextAware ,DisposableBean{
public Test(){
System.out.println("test初始化");
}
public void setBeanName(String arg0) {
System.out.println("Test.setBeanName()");
}
public void setBeanFactory(BeanFactory arg0) throws BeansException {
System.out.println("Test.setBeanFactory()");
}
public void afterPropertiesSet() throws Exception {
System.out.println("Test.afterPropertiesSet()");
}
public void setApplicationContext(ApplicationContext arg0) throws BeansException {
System.out.println("Test.setApplicationContext()");
}
public void destroy() throws Exception {
System.out.println("Test.destroy()");
}
public void init(){
System.out.println("Test.init()");
}
}
以上是关于spring bean的生命周期的主要内容,如果未能解决你的问题,请参考以下文章