spring普通项目中使用方式
方法一:implements ApplicationListener 这个接口
方法二:其实更简单的方法是使用注解:`@PostConstruct`,只需要在需要启动的时候执行的方法上标注这个注解就搞定了。
方法三、方法实现InitializingBean或者ServletContextAware
package org.lanqiao.rpc.demo04_pb_with_netty.demo02_with_rpc.media;
import java.lang.reflect.Method;
import java.util.Map;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
/**
* spring容器初始化成功后,执行,
* @author Administrator
*
*/
//@Component
public class InitMedia implements ApplicationListener,Ordered{
@Override
public void onApplicat