📄 test.java
字号:
package ioc1;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
public class Test {
/**
*
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Resource rs = new ClassPathResource("ioc1\\applicationContext.xml");
BeanFactory bf = new XmlBeanFactory(rs);
//调用配置文件中的相应bean的class创建一个实例
//xml中的bean的id="greetingBean",class="类的全路径"
//property 中的name="属性名" set方式的注入
//property里的value="值" 自动进行类型转换
GreetingBean gb = (GreetingBean)bf.getBean("greetingBean");
gb.sayHello();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -