以前使用spring MVC框架 ,读取properties 配置文件需要写一大堆东西 ,也许 那时候 不怎么使用注解 ,现在使用spring boot ,发现了非常简便的办法---使用注解

2.操作

新建一个配置文件 

my.properties

spring boot  --- 使用 注解 读取 properties 文件 信息  spring boot  --- 使用 注解 读取 properties 文件 信息

 

 在需要调用的类上加注解,参数就是需要获取数据的配置文件名,记得加后缀

@PropertySource("classpath:my.properties")

spring boot  --- 使用 注解 读取 properties 文件 信息

 

 怎么使用呢?

spring boot  --- 使用 注解 读取 properties 文件 信息

 

 

3.测试

spring boot  --- 使用 注解 读取 properties 文件 信息

 

相关文章: