如何使用 Intellij 解决 Java 中的 fileNotFoundException

How do I resolve fileNotFoundException in Java using Intellij

我在 Intellij 上的项目不再是 运行 我的项目,它一直抛出一些编译错误。

我尝试了重建、构建和无效 Cache/Restarted,但我没有成功 我还检查了下面的这个 link,但它对我不起作用:

https://intellij-support.jetbrains.com/hc/en-us/community/posts/206885455-java-Cannot-find-JDK-1-7-for-module

我一直收到这个错误

java.io.FileNotFoundException: /home/byteworks/Documents/Projects/ics-assessment-api/ics-assessment-controller/out/production/resources/customers-template/AGENCY_CUSTOMER_MASTERLIST_TAXPAYER v1.0.xlsx (Permission denied)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
    at com.intellij.openapi.util.io.FileUtil.openOutputStream(FileUtil.java:492)
    at com.intellij.openapi.util.io.FileUtil.performCopy(FileUtil.java:452)
    at com.intellij.openapi.util.io.FileUtil.copyContent(FileUtil.java:447)
    at org.jetbrains.jps.incremental.FSOperations.copy(FSOperations.java:437)
    at org.jetbrains.jps.gradle.compiler.GradleResourceFileProcessor.copyFile(GradleResourceFileProcessor.java:68)
    at org.jetbrains.jps.gradle.compiler.GradleResourcesBuilder.build(GradleResourcesBuilder.java:101)
    at org.jetbrains.jps.gradle.compiler.GradleResourcesBuilder.build(GradleResourcesBuilder.java:28)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildTarget(IncProjectBuilder.java:1037)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1018)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1074)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:968)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:797)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:375)
    at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)
    at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:135)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0[=11=](BuildMain.java:229)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread[=11=](SharedThreadPoolImpl.java:42)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Please perform full project rebuild (Build | Rebuild Project)```

正如其他人所说,权限被拒绝,文件夹或文件是否已被某种形式的保护/防病毒软件移动或更改?

错误似乎是它试图从中复制文件的地方 /home/byteworks/Documents/Projects/ics-assessment-api/ics-assessment-controller/out/production/resources/customers-template/AGENCY_CUSTOMER_MASTERLIST_TAXPAYER v1.0.xlsx

那还是 xlsx 所在的路径吗?也不应该是xslx。

这可能是您在 build.gradle 复制命令中的文件名有错字的问题吗? 看起来你在某种形式的 linux 计算机上,因为你有一个 /home/byteworks 文件夹,你是 byteworks 用户吗?如果没有,您是否有权访问 byteworks 文件夹,因为用户可以限制对其文档文件夹的访问。检查文件所有者和权限,如果你在文件夹中执行 ls -la,那么你可以看到标志, _rwxrwxrwx - 标志是 _ = SetUUID/SetGroup/Sticky 标志 rwx - 所有者权限读写执行(执行也是文件夹的 ls 查看权限) rwx - 组权限 rwx - 其他权限 - 如果最后一个是 ___,这意味着任何不是所有者的人都没有访问该文件的权限。