springboot注解
@Configuration // 等价于<beans></beans>
@Bean // 等价于<bean></bean>
@ComponentScan // 等价于<context:component-scan base-package="com.test.demo"/>
@Import({MessageConverterConfiguration.class}) // 通过快速导入的方式实现把实例注入spring的IOC容器中,有4中方式,可以混合使用:
a.直接注入普通bean
b.导入一个ImportSelector实现,注入ImportSelector返回的全类名数组定义的bean,springboot多使用这种方式
c.导入一个ImportBeanDefinitionRegistrar实现,类似ImportSelector,但更加自定义,注入其定义的bean
d.导入一个@Configuration注解的类,类似@ImportResource
@ImportResource // 导入xml文件,注入其定义的bean
@ConfigurationProperties(prefix = "rocketmq") // 用来把properties配置文件转化为bean,支持松绑定的特性,比@value更方便
@EnableConfigurationProperties(RocketMQProperties.class) // 配合@ConfigurationProperties,将ConfigurationProperties注解的bean注入容器(类似@Component)的开关
@ConditionalOnBean({name = "mQAdmin"}) // 当给定的在bean存在时,则实例化当前Bean
@ConditionalOnMissingBean({name = "mQAdmin"}) // 当给定的在bean不存在时,则实例化当前Bean
@ConditionalOnClass({MQAdmin.class}) // 当给定的类名在类路径上存在,则实例化当前Bean
@ConditionalOnMissingClass({MQAdmin.class}) // 当给定的类名在类路径上不存在,则实例化当前Bean
@ConditionalOnExpression // 当表达式为true的时候,则实例化当前Bean
@ConditionalOnNotWebApplication // 不是web应用
@ConditionalOnProperty(prefix = "rocketmq", value = "name-server", matchIfMissing = true) // 当配置存在,则实例化当前Bean
@AutoConfigureAfter({MessageConverterConfiguration.class}) // 配置类在另一个配置类之后加载
@AutoConfigureBefore({RocketMQTransactionConfiguration.class}) // 配置类在另一个配置类之前加载
@SpringBootApplication // springboot入口定义,等价于@Configuration,@EnableAutoConfiguration,@ComponentScan