1

I'm learning Spring Boot and sometimes I have to config application.properties with values like classpath:/some/packages and file:/some/url. What is the difference between classpath vs file in this situation ?

Neoflies
  • 263
  • 1
  • 3
  • 7

1 Answers1

0

Firstly, you need to understand what the classpath is. Here is a good answer about it:

It would be impractical to have the VM look through every folder on your machine, so you have to provide the VM a list of places to look. This is done by putting folder and jar files on your classpath.

Shortly, classpaths contain:

  • JAR files of your project
  • and Paths to the top of package hierarchies.

So when you have classpath:/some/packages - think of it as you point to a file inside your project (the first / is the root for the compiled classes and resources). But when you have file:/some/url you point to a file anywhere in the OS.

Dmitrii Bocharov
  • 872
  • 6
  • 21