Spring boot Spring application.properties-如何设置windows文件名路径?
我正在尝试重构一个Spring启动应用程序,其中硬编码的CSV文件名将替换为从“application.properties”文件中提取的文件名,如Spring boot Spring application.properties-如何设置windows文件名路径?,spring-boot,Spring Boot,我正在尝试重构一个Spring启动应用程序,其中硬编码的CSV文件名将替换为从“application.properties”文件中提取的文件名,如 outputRoleCsv("d:\\temp\\lean-actor-role.csv",aModel.getActorRoles()); 属性文件中的属性设置为 file.name.actor.role="d:\\temp\\lean-actor-role.csv" 但是,当我用属性派生值替换硬编码文
outputRoleCsv("d:\\temp\\lean-actor-role.csv",aModel.getActorRoles());
属性文件中的属性设置为
file.name.actor.role="d:\\temp\\lean-actor-role.csv"
但是,当我用属性派生值替换硬编码文件名时,我得到一个错误
java.io.FileNotFoundException: "d:\ emp\lean-actor-role.csv" (The filename, directory name, or volume label syntax is incorrect)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:187)
java.io.FileNotFoundException:“d:\emp\lean actor role.csv”(文件名、目录名或卷标语法不正确)
位于java.base/java.io.FileOutputStream.open0(本机方法)
位于java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
位于java.base/java.io.FileOutputStream(FileOutputStream.java:237)
位于java.base/java.io.FileOutputStream。(FileOutputStream.java:187)
这显然与“\”字符有关,但我找不到设置application.properties值的方法
建议?属性文件中不需要双引号。删除双引号,它就会工作
file.name.actor.role=d:\\temp\\lean-actor-role.csv
你有没有试过在删除double引号后。。。好样的!谢谢