Search code examples
springspring-bootspring-cloud-config

What is the difference between using the file:// prefix, and its absence?


I do configure Spring Cloud Config Server. My application.yml looks like the following.

spring:
  cloud:
    config:
      server:
        git:
          uri: ${HOME}/Desktop/configs

I'm interested in the uri parameter. In the documentation https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html it is written that the path is specified so

spring.cloud.config.server.git.uri: file://${user.home}/config-repo

However, without specifying the file:// prefix, as done in my case, everything works. What is the difference between using the file:// prefix, and its absence?


Solution

  • The file:// determines it is going to look on the file system, so you can put relative path and navigate trough the filesystem.

    The classpath:// determines it is going to look on the classpath of your service/project. It's easier to use this one when you want to referrer resources for example

    The default type is file:// but I would advice to have it as prefix, so it is explicit where you are looking at :)

    See more on https://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/resources.html