Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current directory in Spring? [closed]

I've got a little project in Spring. It's located (for example) in C:/users/projects/blog. How can I get this path?

like image 251
Tony Avatar asked Aug 14 '13 17:08

Tony


People also ask

How do I get a present working directory?

The pwd command can be used to determine the present working directory. and the cd command can be used to change the current working directory.

What is ${} in spring boot?

Spring Boot - Using ${} placeholders in Property Files. ☰ LOGICBIG.

Will you get the current working directory in Java?

In Java, we can use System. getProperty("user. dir") to get the current working directory, the directory from where your program was launched.

How do I get the current working directory in Linux?

To print the current working directory, we use the pwd command in the Linux system. pwd (print working directory) – The pwd command is used to display the name of the current working directory in the Linux system using the terminal.


2 Answers

Maybe this what you looking for:

System.getProperty("user.dir")

This property returns user working directory for application.

like image 182
aim Avatar answered Nov 05 '22 13:11

aim


Java cannot determine the root of your project without projects meta data. You can get the absolute path to your current class executing the code using the following : YourClassName.class.getResource("").getPath()

like image 20
vinay Avatar answered Nov 05 '22 14:11

vinay