📄 autowiringdemo1.java
字号:
package test;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;/** * 使用autowire * * @author worldheart */public class AutowiringDemo1 { protected static final Log log = LogFactory.getLog(AutowiringDemo1.class); public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("ac1.xml"); TestBean1 tbByName = (TestBean1)ac.getBean("tbByName"); log.info(tbByName.getTestBean2()); log.info(tbByName.getTestBean3()); TestBean1 tbByType = (TestBean1)ac.getBean("tbByType"); log.info(tbByType.getTestBean2()); log.info(tbByType.getTestBean3()); TestBean1 tbConstructor = (TestBean1)ac.getBean("tbConstructor"); log.info(tbConstructor.getTestBean2()); log.info(tbConstructor.getTestBean3()); TestBean1 tbAutodetect = (TestBean1)ac.getBean("tbAutodetect"); log.info(tbAutodetect.getTestBean2()); log.info(tbAutodetect.getTestBean3()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -