现在我们要在某个地方读取config.properties里的这几个属性值 这里使用三个注解即可读取自定义的配置文件内容(注意这里需要写他的setter和getter方法)
@Component #注入spring容器中 @ConfigurationProperties(prefix = "test") #前缀为test @PropertySource("classpath:config.properties") #配置文件名称路径
然后直接可以提取使用 打印内容: