springcontexttests.java
来自「JAVA做的CMS源码」· Java 代码 · 共 30 行
JAVA
30 行
package com.ponyjava.common.test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public abstract class SpringContextTests {
private static ApplicationContext context;
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
public synchronized ApplicationContext getContext() {
if (context == null) {
context = new ClassPathXmlApplicationContext(getConfigLocations());
}
return context;
}
public Object getBean(String name) {
return getContext().getBean(name);
}
protected String[] getConfigLocations() {
String[] config = new String[] { "test-applicationContext.xml", };
return config;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?