IntelliJ 检查“未处理的异常”和其他多个错误,但项目成功编译 Java SDK 1.6

问题描述

平台:IntelliJ 社区版 2020.3
项目/模块 SDK:jdk1.6.0_45
项目语言级别:6 - 接口中的@Override
模块依赖:jdk1.6.0_45
操作系统:Windows 10

对于这个旧的源代码库,从 Eclipse 移动到 IntelliJ & 我可以看到很多错误,但是当我构建项目时,它可以正确编译。我该如何摆脱这些错误,我无法更新所有类以添加 throw/catch/method 参数注释等。此外,这不是基于 maven 的项目。

Errors: Unhandled exception,Cannot resolve symbol,etc

我到目前为止所做的,阅读其他人的建议:

  • File > Invalidate Caches and restart the IDE 3-4 times
  • File > Settings > Build,Execution,Deployment > Compiler > Java Compiler > Changed Project & Target Bytecode Version to 6

来自.idea dir的一些文件

misc.xml

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" project-jdk-name="1.6" project-jdk-type="JavaSDK" />
</project>

mySourceCode.iml

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6">
    <output url="file://$MODULE_DIR$/out/production/mySourceCode" />
    <output-test url="file://$MODULE_DIR$/out/test/mySourceCode" />
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
      <excludeFolder url="file://$MODULE_DIR$/out" />
    </content>
    <orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Ext_Jars" level="application" />
  </component>
</module>  

module.xml

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectModuleManager">
    <modules>
      <module fileurl="file://$PROJECT_DIR$/.idea/mySourceCode.iml" filepath="$PROJECT_DIR$/.idea/mySourceCode.iml" />
    </modules>
  </component>
</project>

compiler.xml

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="CompilerConfiguration">
    <excludeFromCompile>
      <file url="file://$PROJECT_DIR$/java/test/test.java" />
    </excludeFromCompile>
    <bytecodeTargetLevel target="6">
      <module name="mySourceCode" target="6" />
    </bytecodeTargetLevel>
  </component>
</project>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)