In my project i have forder with database. When i move project to another directory my database url doesn't work. So, I want to create universal method for getting current project path for creating universal database url. I'm looking for a way to get path like this:
C:\Users\UserName\FolderName\ProjectName
Structure of my project: Structure screenshot
答案 0 :(得分:1)
通常,将数据库位置绑定到应用程序的位置(通常最终在JAR中)并不是一个好主意。相反,找出要放置数据库的位置并添加引用。如有必要,可以从命令行或PROPERTIES文件传递位置。请注意,如果将应用程序打包在JAR中,则PROPERTIES方法会遇到问题,因为您无法对其进行修改。