Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the problem of generating file path in springboot and its solution

Shulou Source: shulou.com Published: 2022-06-01 21:19:48 09月18日 Update

This article introduces the problem and solution of generating file path in springboot. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Springboot generate file path

When developing a springboot project and distributing it as a jar package, there may be two cases where the file path is inconsistent. There is a way to get the path so that the root directory of the project or jar package can be correctly obtained in both environments.

For example, String root = System.getProperty ("user.dir"); String path = root + "\\ out.txt"; / / this is the directory where you can get the current jar package runtime.

When the project runs with java-jar xxx.jar in the jar package, jar runs as a separate file and the file is not generated in the jar package.

So use System.getProperty ("user.dir"); to get the path where the current jar is running (the same directory as the jar file), and use that path as the root directory to store the files generated in the project.

Springboot creation error (path)

Error: Cannot download 'https://start.spring.io/starter.zip?type=maven-proje

This happens when you create a springBoot project using idea

Solve

After setting finds HTTP Proxy, select Auto-detect proxy settings, click on the Check connection pop-up input box, and enter the address below

On the problem of generating file paths in springboot and what is the solution to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: File path project run method problem middle student build content situation more root directory directory help input good consistent interest can make sibling Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux NVidia Shulou Tech Info MariaDB macOS