SpringBoot的一些注解

@Component  作用在类上,将对象交给容器管理

@PropertySource("classpath:book.properties")   在类上引入其他配置

@ConfigurationProperties(prefix = "book")  类安全的属性注入,指定配置前缀

 

 

@Value                    将属性注入对象中

 

 1.使用SpringBoot不同配置文件启动

方式一 :在idea中配置,spring.config.name=配置文件名无后缀

 

 方式二:已经打成jar包,项目启动时加上参数

 

posted @ 2020-07-08 14:28  西以北偏北  阅读(102)  评论(0编辑  收藏  举报