beanfactorypreinstantiatesingletonsintegrationtests.java
来自「一些很有用的spring的书籍」· Java 代码 · 共 26 行
JAVA
26 行
package com.apress.springbook.chapter02;
import junit.framework.TestCase;
import org.springframework.core.io.ClassPathResource;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
public class BeanFactoryPreInstantiateSingletonsIntegrationTests extends TestCase {
public void testPreInstantiateSingletons() {
ConfigurableListableBeanFactory beanFactory =
new XmlBeanFactory(
new ClassPathResource(
"com/apress/springbook/chapter02/preInstantiate-singletons.xml"
)
);
assertEquals(0, InstantiationCounterClass.getNumberOfInstantiations());
beanFactory.preInstantiateSingletons();
assertEquals(1, InstantiationCounterClass.getNumberOfInstantiations());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?