java - 找不到符号 intellij gradle

标签 java gradle intellij-idea

这个看似非常简单甚至愚蠢的问题一直困扰着我。

我做了什么:

  1. 在我全新的 Mac OS X 10.13.6 上

  2. 我使用 Intellij CE 2018.1 版本查看了 Github 上的存储库。

  3. 每当我尝试从 Intellij 在此存储库中运行单元测试时,它只会说:“找不到符号”,屏幕截图如下: enter image description here

  4. 我没有在本地进行任何更改,这是我从 git 存储库中 checkout 的构建绿色项目。

  5. 这是 build.gradle 文件

    apply plugin: 'java'
    apply plugin: 'checkstyle'
    
    group = 'com.fishercoder'
    version = '1.0-SNAPSHOT'
    
    checkstyle {
       //include ( '**/*.java')
       configFile = file("${rootDir}/fishercoder_checkstyle.xml")
    }
    
    description = """"""
    
    sourceCompatibility = 1.9
    targetCompatibility = 1.9
    
    repositories {
       mavenCentral()
       maven { url "http://repo.maven.apache.org/maven2" }
    }
    
    dependencies {
        compile 'com.google.code.gson:gson:2.8.0'
        testCompile group: 'junit', name: 'junit', version:'4.12'
    }
    

我尝试过的:

  1. 有趣的是,我可以在 src 代码部分打印出“Hello world”,但 tst 部分只是不要在 Intellij 中编译。
  2. 我已使缓存失效并重新启动 Intelij,但没有成功。
  3. 我已经删除了磁盘上的文件夹,完全关闭我的 Intellij,先将 git clone 到我的磁盘中,然后打开 Intellij 导入它,如下所示: enter image description here

然后将其导入为gradle项目,如下所示: enter image description here

将以下页面上的所有内容保留为默认值: enter image description here

然后在我的 Intellij 控制台中,我收到此错误: enter image description here 如有任何帮助,我们将不胜感激!

最佳答案

看起来,当您导入项目时,Gradle 包装器正在选择与 JDK 10 不兼容的 Gradle 版本 ( See This )。

您可以尝试在系统中手动安装 gradle(最好是高于 4.7 的任何版本)。然后选择“使用本地gradle发行版”选项并在Intellij中指定gradle安装路径。

那你应该没问题!

关于java - 找不到符号 intellij gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52195643/

相关文章:

java - Intellij IDEA 2 :2016. 2.4-1 : Unsupported Java Version: Cannot start under Java 1. 7.0_111-b01 : Java 1. 需要 8 或更高版本

java - 传递 ArrayList 报告显示逗号每个项目

java - 使用集合时验证重复的用户条目

java.lang.ClassNotFoundException : com. microsoft.sqlserver.jdbc.SQLServerDriver 尽管事实上它依赖于 gradle.build 文件

java - Spring Boot消耗Gradle中的REST API

intellij-idea - 在 gradle 项目和 IntelliJ IDEA 项目中同步更改运行非常缓慢

java - 如何反转SelectionSort以降序显示?

java - 无法解释的类型与错误不匹配

Android Studio Gradle : how to configure buildTypes, 并在构建时检查哪种构建类型?

java - 使用 Intellij 在 Java 中重构构造函数