IOC容器是用来管理bean对象的。
AOP则是面向切面编程
Spring要学会配置applicationContext.xml文件。
1.Spring中写bean类型,比如新建一个Boss类,记得加注解
package com.hhwy.spring2018.domain;
public clas Employee{
private String id;
private String userName;
private Integer age;
private Leader myLeader;
public void getId(String id){
this.id=id;}
public String getId{
return id;}
public void setUserName(String userName){
this.userName=userName;}
public String getUserName{
return userName;}
public void setAge(Integer age){
this.age=age;}
public Integer getAge{
return age;}
public void setLeader(Leader leader){
this.leader=leader;}
public Leader getLeader{
return leader;}
@Override
public String toString(){
return "Employee[id="+id+",userName="+userName+",age="+age+",leader="+leader+"]";
}
2.建立一个测试类,进行测试的时候,用鼠标选中方法,有@Test注解..如test1,选中方法名,鼠标右键点击JUnit Test 将其运行起来
public class TestHelloworld{
ClassPathXmlApplicationContext ioc;
@Test
public void test1{
Employee employee=(Employee)ioc.getBean("employee");
System.out.println(employee);
}
3. applicationContext.xml是这样子写的