}
}
package test.java;
import org.springframework.context.ApplicationContext;
import
org.springframework.context.support.FileSystemXmlApplicationContext;
public class TestHelloWord {
public static void main(String[] args){
ApplicationContext actx = new
FileSystemXmlApplicationContext("config.xml");
HelloWord helloWord = (HelloWord) actx.getBean("HelloWord");
System.out.println(helloWord.getMsg() + helloWord.getDate());
}
}
建立在最外层目录,与 同级
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="HelloWord" class="test.java.HelloWord">