⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.java

📁 加拿大达内科技有限公司配需java程序员的上课时的代码
💻 JAVA
字号:
package ioc2;
/**
 * BeanFactory 和ApplicationContext
 * 1.BeanFactory 是所有容器的父接口,提供了基本的对象的装配支持
 * 	(1) getBean("  ") Bean的名称 <bean id="">或<bean name="">
 * 		Bean的名称不允许重复。
 * 	(2) XmlBeanFactory 是其实现
 * 	(3) 只有调用getBean()方法时,容器才会创建对应的实例
 * 2.ApplicationContext是BeanFactory 的接口,增加了事件处理,国际化等支持。
 * 	(1)ClassPathXml 是其实现。
 * 	(2)预先实例化Bean(只对scope="single")
 */
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//事务处理
		//ApplicationContext ac = new ClassPathXmlApplicationContext("ioc2\\applicationContext.xml");
		ApplicationContext ac = new ClassPathXmlApplicationContext(new String[]{"ioc2\\applicationContext.xml","ioc2\\otherContext.xml"});
		SomeBean sb = (SomeBean)ac.getBean("someBean");
		sb.printInfo();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -