本文介绍了在 Mac OSX 上运行 IntelliJ 中的第一个 playframework 示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在我的新 Mac OSX 10.8.3 中,我安装了 Scala 2.10.0,玩了 2.1.0 和 IntelliJ12,并创建一个播放项目如下:

In my new mac OSX 10.8.3,I install scala 2.10.0, play 2.1.0 and IntelliJ12,and create a play project as follows:

#install brew
> ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
> brew --version
0.9.4

# update brew database
> cd $(brew --prefix)
> brew update
> cd $(brew --prefix) && git pull --rebase

# get scala 2.10.0
> brew versions scala
2.10.1   git checkout 79dc6f1 Library/Formula/scala.rb
2.10.0   git checkout 8ca07aa Library/Formula/scala.rb
2.9.2    git checkout 8896425 Library/Formula/scala.rb
...

> git checkout 8ca07aa Library/Formula/scala.rb   # 2.10.0
> brew install scala
> scala -version
Scala code runner version 2.10.0 -- Copyright 2002-2012, LAMP/EPFL


# install play 2.1.0
> brew versions play
2.1.0    git checkout 6a70797 Library/Formula/play.rb
...

> brew install play
> play -version
play! 2.1.0 (using Java 1.6.0_43 and Scala 2.10.0), http://www.playframework.org

然后我创建了一个播放应用程序:

and I create a play application:

> cd ~/
> play new myapp
name: myapp
Create a simple Scala application

# generate IntelliJ project:
> cd myapp
> play
> idea
[info] Created /Users/david/myapp/.idea_modules/myapp.iml
[info] Created /Users/david/myapp/.idea_modules/myapp-build.iml

并在 IntelliJ 中打开项目:

and open the project in IntelliJ:

# Install IntelliJ 12 Ultimate Edition
Download it from http://www.jetbrains.com/idea/
12.0.4, Build #IU-123.169
Build on February 13, 2013

# install scala plugin in IntelliJ
run IntelliJ,
Preferences -> plugins -> Browse from repositories -> add scala.
current version: 0.7.134

# open myapp project in IntelliJ
File -> Open Project, chose the directory /Users/david/myapp

然后当我尝试运行单元测试时:

Then when I try to run the unit test:

Project -> myapp -> test -> ApplicationSpec -> (right click) -> Run

我收到此错误:

scala: Сompiler library for module bigbrother not found: Right(Project) / Right(scala-2.10.0)

其实有几个错误:

in File -> Project Structure -> Modules, there are two modules:
-myapp
-mypp-build

File -> Project Structure -> Modules -> myapp -> Scala
   Compiler library: scala-2.10.0 [not found]
   <<< ERROR

File -> Project Structure -> Modules -> myapp-build -> Dependencies:
   scala-2.9.2
   <<< ERROR

如果我纠正第一个错误如下,

If I correct the first error as follows,

File -> Project Structure -> Modules -> myapp -> Scala -> Compiler library
and from the dropdown list I select the second valid option "scala-2.10.0 (version 2.10.0)".

然后,重新运行测试,产生错误:

Then, re-running the test, produces the error:

scala: Output path /Users/david/bigbrother/project/target/scala_2.9.2 is shared between: Module 'bigbrother-build' production, Module 'bigbrother-build' tests
Currently external Scala compiler prohibits output path sharing.
Either disable the external build mode or configure separate output paths.
TIP: you can use Project Artifacts to combine compiled classes.

我需要做什么才能让它发挥作用?

What do I need to do to make it work?

更新:基于 Marius 和 alexwriteshere 的答案的解决方案

> cd myapp
> play
> idea no-sbt-build-module

(而不仅仅是想法")

那么,项目设置 -> 库选择Scala 2.9.2"并点击-"将其删除.

then,Project Settings -> LibrariesSelect "Scala 2.9.2" and click on "-" to remove it.

那么,项目设置 -> 模块 -> my_app -> Scala -> Scala-compiler在这个下拉列表中,选择了红色的Scala 2.10.0".移至列表顶部,然后选择以黑色/灰色书写的Scala 2.10.0(版本 2.10.0)".

then,Project Settings -> Module -> my_app -> Scala -> Scala-compilerin this dropdown list, there is selected "Scala 2.10.0" written in red.move to the top of the list, and select "Scala 2.10.0 (version 2.10.0)" written in black/grey.

注意

有时(我不知道为什么)下拉列表中没有选择用黑色/灰色编写的Scala 2.10.0(版本 2.10.0)".一种适用于我使其可用的解决方法如下:项目设置 -> 全局库 -> + -> Java从此目录中选择这些文件 scala-compiler.jar、scala-library.jar 和 scala-reflect.jar:/usr/local/Cellar/scala/2.10.0/libexec/lib/选择确定.将其命名为我的 scala 2.10.0 包".

sometimes (I don't know why) the choice "Scala 2.10.0 (version 2.10.0)" written in black/grey is not available in the dropdown list.a workaround that works for me to make it available is as follows:Project Settings -> Global Libraries -> + -> Javaselect these files scala-compiler.jar, scala-library.jar and scala-reflect.jar from this directory: /usr/local/Cellar/scala/2.10.0/libexec/lib/select Ok.Give it the name "my scala 2.10.0 bundle".

然后,再次进入 Project Settings -> Module -> my_app -> Scala -> Scala-compiler现在你有了两个,你刚刚创建的我的 scala 2.10.0 包"和标准的:Scala 2.10.0(版本 2.10.0)"用黑色/灰色编写.选择标准的,删除你创建的全局库.

then, go again to Project Settings -> Module -> my_app -> Scala -> Scala-compilernow you have both, the one you just created "my scala 2.10.0 bundle", and the standard one: "Scala 2.10.0 (version 2.10.0)" written in black/grey. select the standard one, and delete the global library you created.

我不知道为什么会发生这种情况,而且我真的不想花更多的时间来找出这个问题.目前,这种解决方法对我有用.但如果您发现了,请随时添加评论.

I don't know why this happens, and I really don't want to spend more time finding this out. for the moment, this workaround works for me. but feel free to add a comment if you find out.

推荐答案

这个问题可以通过生成idea项目解决:

This problems can be solved by generating the idea project with:

$ play  # start play from command line
[your-play-project] $ idea no-sbt-build-module

这将启用 IntelliJ 对 Scala 的默认构建机制,这不会导致这些问题.

This will enable IntelliJ's default building mechanism for Scala, which won't cause these problems.

这篇关于在 Mac OSX 上运行 IntelliJ 中的第一个 playframework 示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:19