|
@ -3,6 +3,7 @@ package com.yihu.hos.web.framework.util.springutil;
|
|
|
|
|
|
import org.springframework.beans.BeansException;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|
|
|
|
|
/**
|
|
|
* 服务管理器。服务管理器是所有顶级服务的生成器。若是单元测试使用此服务工厂,Spring Context会被ServiceFactory创建。
|
|
@ -27,7 +28,6 @@ public class SpringBeanUtil {
|
|
|
|
|
|
public static void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
|
springContext = applicationContext;
|
|
|
System.out.println("springBeanUtil 初始化成功~,springContext is null: "+ (springContext==null));
|
|
|
}
|
|
|
|
|
|
public static <T> T getBean(String beanName){
|
|
@ -43,15 +43,15 @@ public class SpringBeanUtil {
|
|
|
* @return
|
|
|
*/
|
|
|
public static <T> T getService(String serviceName) {
|
|
|
// if (springContext == null) {
|
|
|
// springContext = new ClassPathXmlApplicationContext(new String[]
|
|
|
// {
|
|
|
// "spring/applicationContext.xml"
|
|
|
// }
|
|
|
// );
|
|
|
// }
|
|
|
|
|
|
return (T) getApplicationContext().getBean(serviceName);
|
|
|
if (springContext == null) {
|
|
|
springContext = new ClassPathXmlApplicationContext(new String[]
|
|
|
{
|
|
|
"spring/applicationContext.xml"
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
|
|
|
return (T) springContext.getBean(serviceName);
|
|
|
}
|
|
|
|
|
|
/**
|