因为对于一些注解不太了解,做下记录说明
======================================================================
1、@Bean:告诉Spring,一个带有@Bean的注解方法将返回一个对象,该对象应该被注册为在Spring应用程序上下文中的bean。
2、@Configuration::一般标识在类上,表明这个类将作为springBean注入到Spring IoC容器。
例如:
<beans>
<bean id = "car" class="com.test.Car">
<property name="wheel" ref = "wheel></property>
</bean>
<bean id = "wheel" class="com.test.Wheel"></bean>
</beans>
相当于:
@Configuration
public class Conf {
@Bean
public Car car() {
Car car = new Car();
car.setWheel(wheel());
return car;
}
@Bean
public Wheel wheel() {
return new Wheel();
}
}
3、@EnableAutoConfiguration:自动配置spring的上下文,猜测和配置你想要的bean类,通常会自动根据你的类路径和你的bean定义自动配置。
4、@ComponentScan:会自动扫描指定包下的全部标有@Component的类,并注册成bean,当然包括@Component下的子注解@Service,@Repository,@Controller。
5、@SpringBootApplication = @Configuration + @EnableAutoConfiguration + @ComponentScan。(用于标识SpringBoot启动类)
6、@ConfigurationProperties(prefix="my"):将前缀为"my"的属性注入进配置类对应属性上(赋值)。
7、@EnableConfigurationProperties:使@ConfigurationProperties生效。
8、@Inherit:一般加在父类注解上面,以便一个子类想获取到父类上的注解信息。