Spring Boot之配置属性获取

Spring Boot之配置属性获取

1.@PropertySource 类名上面添加注解

@PropertySource({"classpath:application.properties"})

2.@ConfigurationProperties 注解可以设置 key 的前缀

@ConfigurationProperties(prefix = "test")

3.对要配置的属性添加注解

@Value("${web.file.path}")
private String filePath;
posted @ 2021-10-26 21:44  码途漫漫  阅读(83)  评论(0)    收藏  举报