1.要注入的类
package test10month.test1018;
public class Addd {
private int i;
@Override
public String toString() {
return "Addd{" + "i=" + i + '}';
}
public int getI() {
return i;
}
public void setI(int i) {
this.i = i;
}
}
2. 函数式注册对象
package test10month.test1018;
import org.springframework.context.support.GenericApplicationContext;
public class Null {
public static void main(String[] args) {
GenericApplicationContext context = new GenericApplicationContext();
context.refresh();
context.registerBean(Addd.class, Addd::new);
Addd bean = context.getBean(Addd.class);
System.out.println(bean);
}
}