上载期间无法将类路径识别为文件路径

时间:2019-05-11 16:07:31

标签: java

尝试在测试环境中上载文件时,始终会出现以下错误:

2019-05-11 17:00:59.934 DEBUG 17380 --- [io-8080-exec-10] com.test.api.sermon.SermonService         : Writing file to local storage as environment is not LIVE
2019-05-11 17:00:59.934 DEBUG 17380 --- [io-8080-exec-10] com.test.api.sermon.SermonService         : File Path: classpath://resources/upload/2019-05-11~Test~Test1.mp3
java.io.IOException: The filename, directory name, or volume label syntax is incorrect at java.io.WinNTFileSystem.createFileExclusively(Native Method)

这是我的代码:

if(activeProfile.equals("dev") || activeProfile.equals("uat")) {
    LOGGER.debug("Writing file to local storage as environment is not LIVE");
    sermonPath = applicationConfiguration.getSermonPath() + fileName;
    if(LOGGER.isDebugEnabled()){
        LOGGER.debug("File Path: " + sermonPath);
    }
    sermonFile = new File(sermonPath);
    sermonFile.createNewFile();
    FileOutputStream fOut = new FileOutputStream(sermonFile);
    fOut.write(sermon.getBytes());
    fOut.close();
}

该目录存在于我的类路径中:

enter image description here

我的Spring配置如下:

application.sermon_path=classpath://resources/upload/

发生这种情况有什么原因吗?

0 个答案:

没有答案