SpringBoot常见注解的解释 @Component @ConfigurationProperties(prefix = "school") @PropertySource(value = "classpath:school.properties")

SpringBoot常见注解的解释
@Component
@ConfigurationProperties(prefix =

这个注解类似SSM中的Controller和Service注解 ,将加了这个注解的类装配到Sping容器内,这样就可以在其他类用@Autowired注解实现依赖注入。

@ConfigurationProperties(prefix = "school")

这个注解是读取外部自定义配置文件  prefix一定要加不然会报错找不到  这里的作用就是查找外部是否有前缀为school的属性,如果有就读取

@PropertySource(value = "classpath:school.properties")

这里直接指定properties文件的位置