0

application.properties path.repository=/repository

When I execute the jar file from the project folder, the path defined in the application.properties works fine and it founds the folder. But if I execute it from any other folder, the path is relative to this folder.

For example, path is spring/project/repository

  • From project folder -> java -jar target/SNAPSHOT.jar -> Repository path is spring/project/repository
  • From spring folder -> java -jar project/target/SNAPSHOT.jar -> Repository path is spring/repository

I have tried classpath:/repository, but it only finds the file if it is in the src/main/resources

fonkys
  • 1
  • 2
  • Does this help? https://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file - In general I'd think about that requirement though: if it can be any path then use an absolute path, if it needs to be relative to the jar then think about whether it could be bundled with the jar. – Thomas Sep 22 '22 at 15:56
  • try copying the repository with pom resource filter to your resource folder and call from classpath:/repository https://docs.spring.io/spring-boot/docs/2.0.0.M7/reference/html/howto-properties-and-configuration.html#howto-automatic-expansion-maven – namila007 Sep 23 '22 at 04:22

0 Answers0