是Sprnig Boot项目的核心注解,目的是开启自动配置
@SpringBootApplication
public static void main(String[] args) {
SpringApplication app = new SpringApplication(Application.class);
app.setAddCommandLineProperties(false);
app.run(args);
}
@ConfigurationProperties
@ConfigurationProperties注解用于自动配置绑定,可以将application.properties配置中的值注入到bean对象上。
该注解使用必须将对象注入到IOC容器中才有配置绑定的功能。也可以将其他 .properties 值绑定需要使用 @PropertySource("classpath:**.properties") 注解声明
把普通pojo实例化到spring容器中
@PropertySource加载指定的属性文件(*.properties)到 Spring 的 Environment 中。可以配合 @Value 和 @ConfigurationProperties 使用。
@EnableConfigurationProperties 在@ConfigurationProperties的使用,把配置类的属性与yml配置文件绑定起来的时候,还需要加上@Component注解才能绑定并注入IOC容器中,若不加上@Component,则会无效。
@EnableConfigurationProperties的作用:则是将让使用了 @ConfigurationProperties 注解的配置类生效,将该类注入到 IOC 容器中,交由 IOC 容器进行管理,此时则不用再配置类上加上@Component。
映射查询结果到实体类, 使用后可以用 @ResultMap 复用



