在Spring Boot中的application.properties中获取用户主路径 [英] Getting the user home path in application.properties in Spring Boot
问题描述
这应该是一个非常直接的任务,但是在进行了大量研究之后,我发现很难找到任何一种方法来实现此目的.
This should be a quite straight forward task, but after doing quite a bit of research I'm finding it hard to find any way to do this.
I just want to create a log file in the current user's home directory. According to the Official Documentation the variables I should modify are logging.file
and logging.path
. But how do I get the value of the user-home into the logging.path
?
我尝试将其设置为:
logging.path=#{systemProperties['user.home']}
但没有成功.
推荐答案
我相信我已经解决了问题.仅当从IDE(Eclipse Luna FYI)运行时,实际上才在类路径中生成有问题的日志文件.稍后,当我制作一个jar文件并运行它时,日志文件是在application.properties
文件中指定的正确位置生成的.当我从Eclipse运行它时,我仍然不知道为什么它是在类路径中生成的.
I believe I have solved the problem. The log file in question was actually being generated in the class path only when run from the IDE (Eclipse Luna FYI). Later on when I made a jar file and ran that, the log file was being generated in the right location as specified in the application.properties
file. I still have no clue to why it was generated in the class path when I ran it from Eclipse.
这篇关于在Spring Boot中的application.properties中获取用户主路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!