在要用的类上添加注解

@PropertySource({"classpath:/properties文件路径"})

引入数据值

@Value("${spring.datasource.url}")
private String url;

 

然后调用,完成

 

 

文件目录

Springboot使用@value注解,引入properties

 

注解注入properties文件资源

Springboot使用@value注解,引入properties

 

设置数据

Springboot使用@value注解,引入properties

之后调用就行

 

源自于此 : 

https://blog.csdn.net/hry2015/article/details/72353994/

相关文章:

  • 2021-06-23
  • 2021-07-30
  • 2021-06-17
  • 2021-09-01
  • 2021-10-31
  • 2021-07-12
  • 2022-01-20
  • 2022-12-23
猜你喜欢
  • 2021-11-05
  • 2022-12-23
  • 2022-02-09
  • 2021-12-15
  • 2021-12-14
  • 2022-01-23
  • 2022-12-23
相关资源
相似解决方案