main.java
来自「JSP高级程序员网络开发源代码」· Java 代码 · 共 22 行
JAVA
22 行
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 + =
减小字号Ctrl + -
显示快捷键?