Spring Beans.xml多种注入
多种类型的注入方式
对象的属性
beans.xml
<?xml version="1.0" encoding="UTF-8"?>
红楼梦
三国
水浒
西游
听歌
打球
看电影
lol
QQ
war3
PC9527
C栋301
test
import com.liu.pojo.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MyTest {
public static void main(String[] args) {
ApplicationContext Context = new ClassPathXmlApplicationContext("beans.xml");
Student stName = (Student) Context.getBean("StName");
System.out.println(stName.toString());
}
}