How to get spring boot application jar parent folder path dynamically?

前端 未结 3 787
囚心锁ツ
囚心锁ツ 2021-02-20 06:16

I have a spring boot web application which I run using java -jar application.jar. I need to get the jar parent folder path dynamically from the code. How can I

3条回答
  •  抹茶落季
    2021-02-20 07:02

        File file = new File(".");
        logger.debug(file.getAbsolutePath());
    

    This worked for me to get the path where my jar is running, I hope this is what you are expecting.

提交回复
热议问题