2018-04-16 16:02

@shihy 可能是版本不一样,我用的是jfinal3.3

2018-04-16 16:02

@shigy_007
public class BeanFactory implements ApplicationContextAware {

private static ApplicationContext ctx;

public static Object getBean(String name) {
return ctx.getBean(name);
}

public static T getBean(Class requiredType) {
return ctx.getBean(requiredType);
}

public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
ctx = applicationContext;
}
}
在spring配置里定义BeanFactory即可,