package com.service;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@Component
public class UserService implements SmartInitializingSingleton, InitializingBean, DisposableBean, BeanNameAware {
public UserService(){
System.err.println(" userService 构造方法 ");
}
@PostConstruct
public void testPostConstruct(){
System.err.println(" PostConstruct ");
}
@PreDestroy
public void testPreDestroy(){
System.err.println(" PreDestroy ");
}
@Override
public void afterSingletonsInstantiated() {
System.err.println(" SmartInitializingSingleton.afterSingletonsInstantiated ");
}
@Override
public void afterPropertiesSet() throws Exception {
System.err.println(" afterPropertiesSet ");
}
@Override
public void destroy() throws Exception {
System.err.println(" destroy ");
}
@Override
public void setBeanName(String name) {
System.err.println(" name : " + name);
}
}
spring[6]-SmartInitializingSingleton, InitializingBean, DisposableBean, BeanNameAware
最新推荐文章于 2022-10-04 22:30:25 发布