什么是 JavaConfig?

千锋教育

JavaConfig是Spring3.0新增的概念,就是以注解的形式取代Spring中繁琐的xml文件。JavaConfig结合了xml的解耦和java编译时检查的优点。


- @Configuration,表示这个类是配置类;


- @ComponentScan,相当于xml的;


- @Bean,相当于xml的;


- @EnableWebMvc,相当于xml的;


- @ImportResource,相当于xml的;


- @PropertySource,用于读取properties配置文件;


- @Profile,一般用于多环境配置,激活时可用@ActiveProfile("dev")注解;