简体   繁体   English

Spring Framework在具有Windows驱动器号的路径上失败

[英]Spring Framework fails on paths with Windows Drive Letters

I am using Spring Framework version 4.3.18.RELEASE under Intellij on Windows 7. I am looking at the decompiled code of, for example, the class 我正在Windows 7上的Intellij下使用Spring Framework版本4.3.18.RELEASE。我正在查看该类的反编译代码。

org.springframework.core.io.DefaultResourceLoader

and the method 和方法

public Resource getResource(String location).

In that code it has a test for 在该代码中有一个测试

location.startsWith("/")

This fails when the location is an absolute Windows path with a leading drive letter. 当位置是带有前导驱动器号的绝对Windows路径时,此操作将失败。 Eg 例如

d:/git/thredds/dap4/d4tests/src/test/resources/

Is there a known alternate specification of such a path that will work? 是否有已知的替代规范可以使用?

Did you try with double slash and reverse slash? 您是否尝试过双斜杠和反斜杠? Like 喜欢

C:\\Users\\...

or 要么

C:\Users\...

try something like 尝试类似

 getResource("file:d:\\git\thredds\blah.txt") 

in case the file is stored along your classes 如果文件是沿着您的班级存储的

getResource("classpath:com/my/package/testing.txt");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM