@Configuration
基于 Java 的配置选项@Configuration
不需要xml将java类作为配置
用@Bean注解定义一个bean
@Configuration
public class config(){
@Bean
public Student Student(){
return new Student();
}
}
上面相等于是
<beans>
<bean id = "Student" class="...Student"/>
<beans>
如何使用
//加载这个配置类
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(config.class);
context.getBean("name");
标签:Bean,Student,new,注解,Configuration,config
From: https://www.cnblogs.com/tsqo/p/16929805.html