1、通用方法:
// 数据库日志操作对象
private LogInfoServiceIFC logInfoServiceProxy;
@Override
public void contextInitialized(ServletContextEvent event) {
WebApplicationContext context = WebApplicationContextUtils
.getRequiredWebApplicationContext(event.getServletContext());
logInfoServiceProxy = (LogInfoServiceIFC) context.getBean("logInfoService");
}
2、SpringMVC项目可直接在类中加入下面这句话:
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
被坑了好几次
时间: 2024-11-06 06:44:19