外置配置文件

Spring程序会按优先级从下面这些路径来加载application.properties配置文件

  • 当前目录下的/config目录
  • 当前目录
  • classpath里的/config目录
  • classpath 跟目录

注意当前目录是指你执行命令所在的目录,可以用系统属性System.getProperty("user.dir")获得执行命令的目录(网上很多说是jar包的当前目录是错误的

例如:在E盘根目录执行命令,打印System.getProperty("user.dir"),结果为E:\  (图1)

在E:\extract-plugin 执行命令,打印System.getProperty("user.dir"),结果为E:\extract-plugin (图2)

springboot外部配置文件引用

springboot外部配置文件引用

springboot外部配置文件引用

参考:https://www.cnblogs.com/zdz8207/p/java-jar-springboot-config.html

相关文章:

  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
猜你喜欢
  • 2021-07-03
  • 2021-10-06
  • 2021-08-28
  • 2021-08-09
  • 2021-08-17
  • 2022-12-23
  • 2021-11-11
相关资源
相似解决方案