System.getProperty(“user.dir”) does not work

后端 未结 1 1713
悲&欢浪女
悲&欢浪女 2021-01-13 15:43

I need to get relative path from my project to upload photos, however when I run System.getProperty(\"user.dir\"); in my test, it returns /home/user/works

相关标签:
1条回答
  • 2021-01-13 16:15

    The user.dir property is the current working directory where you are running Java. You're starting java in /home/user/workspace/Myproject when you run your project but when Spring runs it, it's not guaranteed to be the same working directory. Are you looking for user.home (which should always be /home/user) instead?

    0 讨论(0)
提交回复
热议问题