一些注解的解释
(1)@Conditional
-
可以通过条件控制是否注入Bean
-
小例子

(2)@ConditionalOnClass
-
Classpath里有指定的类时起效
-
小例子

(3)@ConditionalOnBean
-
DI容器中存在该类型Bean时起效
-
小例子


(4)@Configuration,@Bean

@Configuration的proxyBeanMethods属性:

相当于spring中的@scope:

(5)@Component

(6)@Import

(7)@ImportResource

(8)配置注解 @EnableConfigurationProperties , @ConfigurationProperties
方式一:


方式二:如果指定的配置目标类没有注册到容器中(即没有@Component注解),则在配置类上使用@EnableConfigurationProperties



(9)@Mapper 和 @Repository

(10)@EnableTransactionManagement
开启事务管理,等同于xml配置方式的 <tx:annotation-driven />
-
xml方法配置事务详见:https://www.cnblogs.com/kakafa/p/15777786.html
-
@EnableTransactionManagement解释详见:https://www.cnblogs.com/kesimin/p/9546225.html
浙公网安备 33010602011771号