三、使用Java进行Spring配置
Spring Configuration Using Java - 章节
无applicationContext.xml方式
Too much XML
Namespaces helped
Enter Java Configuration
Everything available
示例:
复制项目,并open复制的项目
更改iml文件名称
更改pom.xml文件里的项目名称
更改应用执行 的配置
再次执行应用成功
注解方式
@Configuration
applicationContext.xml replaced by @Configuration
@Configuration at class level
Spring Beans defined by @Bean
@Bean at method level
App配置
Setter注入
构造函数注入
总结:
App配置
@Configuration
@Bean
Setter、构造函数注入