📄 main.java
字号:
package com.jspdev.ch20;
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 Main {
public static void main(String[] args) {
// 直接调用HelloBean
HelloBean helloBean = new HelloBean();
System.out.println(helloBean.getHelloWorld());
// 利用Spring调用HelloBean
Resource res = new ClassPathResource("com/jspdev/ch20/bean.xml");
BeanFactory factory = new XmlBeanFactory(res);
helloBean = (HelloBean) factory.getBean("helloBean");
System.out.println(helloBean.getHelloWorld());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -