package com.huangwz.spring.SpringDemo6;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
public class HelloBean {
private String helloWord;
private Date date;
public String getHelloWord() {
return helloWord;
}
public void setHelloWord(String helloWord) {
this.helloWord = helloWord;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
package com.huangwz.spring.SpringDemo6;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringDemo {
public static void main(String[] args) {
ApplicationContext context=new ClassPathXmlApplicationContext("beans-config.xml");
HelloBean helloBean=(HelloBean) context.getBean("helloBean1");
System.out.println("word="+helloBean.getHelloWord());
System.out.println("Date="+helloBean.getDate());
}
}