在scala项目中,编译器错误 - 无法解析符号列表? [英] at scala project, compiler error - Cannot resolve symbol List?

查看:1125
本文介绍了在scala项目中,编译器错误 - 无法解析符号列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全是Scala的新手。

我在Ubuntu 12.04上安装了java,sbt和scala:

I'm completely newly at Scala.
I installed java, sbt and scala on Ubuntu 12.04:

nazar_art@nazar-desctop:~$ sbt sbt-version
[warn] Alternative project directory .sbt (/home/nazar_art/.sbt) has been deprecated since sbt 0.12.0.
[warn]   Please use the standard location: /home/nazar_art/project
[info] Loading project definition from /home/nazar_art/.sbt
[info] Set current project to default-5b9232 (in build file:/home/nazar_art/)
[info] 0.12.4
nazar_art@nazar-desctop:~$ scala -version
Scala code runner version 2.10.2 -- Copyright 2002-2013, LAMP/EPFL
nazar_art@nazar-desctop:~$ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)

我在想法中安装了scala和sbt插件。

I installed scala and sbt plugins to Idea.

当我尝试第一个示例项目时,我看到下一个错误:

And when I tried irst example project I see next error:

在下一行之后无法解析符号列表:

Cannot resolve symbol List, after next lines:

package example    
import common._

object Lists {      
  def sum(xs: List[Int]): Int = {   // <== here underline for List
    if (xs.isEmpty) 0
    else xs.head + sumList(xs.tail)
  }    
}

我无法想象究竟出了什么问题?
IDEA建议我导入 java.util.List - 但是这个类没有任何 isEmpthy()方法。

有什么建议吗?

I couldn't figure out what exactly is wrong? IDEA suggest me importing java.util.List - but this class doesn't have any isEmpthy() method.
Any suggestion?


  • 如何解决这个问题?

更新:


  • 我重新安装了新版本的 IntelliJ IDEA 13社区
    版本

    而非#12。未加入 / usr / local / Idea

  • 删除了sbt - sudo apt-get purge sbt 。并重新安装这个
    脚本

  • 我去了 / MyProjectDirectory / project / 并创建了'plugin.sbt'
    ,内容为:

  • I reinstalled newly version of IntelliJ IDEA 13 Community Edition instead of # 12. Untared in /usr/local/Idea.
  • Removed sbt - sudo apt-get purge sbt. And reinstall accord this script.
  • I went to /MyProjectDirectory/project/ and created 'plugin.sbt' with content:

addSbtPlugin(com.github.mpeltonen%sbt-idea%1.5.1)

在此之后,我从我的项目目录 sbt gen-idea 中输入。它为
重建了Idea的项目。

After this I type from my project directory sbt gen-idea. It rebuild project for Idea.

它应该足够但它再次显示:

It should be enough but it shown again:

Cannot resolve symbol List

并建议导入 import scala.collection.immutable.List 。但这没有用。它继续用红线加下划线。

and suggesting import import scala.collection.immutable.List. But this isn't helpful. It keep being underlined with red line.

推荐答案

如果您的IDEA插件没有看到scala类,请转到文件 - >项目结构并检查以下内容:

If your IDEA plugin doesn't see scala classes then go to File -> Project Structure and check the following:


  1. 确保将Scala Facet添加到您的应用程序中。转到构面选项卡,检查是否列出了Scala构面。如果没有,您需要添加和配置它。然后确保Scala Facet列在需要Scala的所有模块下。

  1. Make sure the Scala Facet is added to your application. Go to the Facets tab and check if Scala facet is listed there. If not, you need to add and configure it. Then make sure that Scala Facet is listed under all the modules that need Scala.

确保Scala Facet使用正确版本的scala库(Idea将如果找不到,请用红色标记。)

Make sure the Scala Facet uses the right version of your scala library (Idea will mark it with red, if it cannot be found).

确保scala-library.jar位于使用Scala的模块的依赖项列表中。检查路径是否正常。

Make sure scala-library.jar is on the list of dependencies of the modules using Scala. Check if paths are ok.

这篇关于在scala项目中,编译器错误 - 无法解析符号列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆