Spring新特性:
在类里可以不用new User()
通过GenericApplicationContext注册对象到Bean里,交给IOC容器管理
//1、创建GenericApplicationContext对象
GenericApplicationContext context = new GenericApplicationContext();
//2、清空context内已有对象,准备注册对象
context.refresh();
// beanid
context.registerBean("account1",Account.class,()->new Account());
Account account = context.getBean("account1", Account.class);
System.out.println(account);
然后我发现一写lambda就报错 lambda expressions are not supported at languege
发现mvn导spring自带的java5,不支持lambda
解决链接