Spring4x和Spring Boot推荐配置的方式管理Bean?

Spring4x和Spring Boot推荐配置的方式管理Bean。

--reading 《Spring Boot实战》。

Java配置是通过@Configuration & @Bean来实现的。

@Configuration 声明当前类是一个配置类,相当于一个Spring配置的xml文件。

@Bean 注解在方法上,声明当前方法的返回值为一个Bean。

本书推荐的配置方式:全局配置使用Java配置(如数据库相关配置、MVC相关配置),业务bean的配置使用注解配置(@Service/@Component/@Repository/@Controller)。


猜你喜欢

转载自blog.csdn.net/huanlegu0426/article/details/80767129
今日推荐