使用file://前缀和不存在前缀有什么区别?

问题描述 投票:0回答:1

我确实配置了Spring Cloud Config Server。我的application.yml如下所示。

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

我对uri参数感兴趣。在文档https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html中写明了指定路径,因此

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

但是,在我的情况下,没有指定file://前缀,一切正常。使用file://前缀和不使用前缀有什么区别?

spring spring-boot spring-cloud-config
1个回答
1
投票

file://确定它将在文件系统上显示,因此您可以放置​​相对路径并浏览文件系统。

classpath://确定它将在您的服务/项目的类路径上查找。例如,当您要引荐resources时,使用此选项会更容易

默认类型为file://,但我建议将其作为前缀,因此在查看的地方它是明确的:)

查看https://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/resources.html的更多信息

© www.soinside.com 2019 - 2024. All rights reserved.