简体   繁体   English

Spring ClassPathRessource 在eclipse下得到错误的路径

[英]Spring ClassPathRessource get wrong path under eclipse

I use new ClassPathResource("myFolder") to get some files from this folder "myFolder".我使用new ClassPathResource("myFolder")从这个文件夹“myFolder”中获取一些文件。

File file = new ClassPathResource("myFolder").getFile();

This returns file path my-project\build\ eclipse \test\myFolder instead of my-project\build\test\myFolder这将返回文件路径 my-project\build\ eclipse \test\myFolder 而不是 my-project\build\test\myFolder

How can I fix it?我该如何解决?

It seems that you have a classpath issue in eclipse.看来您在 Eclipse 中有一个类路径问题。 The result that you're getting is like that because eclipse does it's own voodoo when youre building and running the application.你得到的结果是这样的,因为当你构建和运行应用程序时,eclipse 做了它自己的巫术。

Check your classpath in eclipse (and also in the Run Configurations).在 Eclipse 中检查您的类路径(以及在运行配置中)。

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

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