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

问题描述

在我的新mac OSX 10.8.3中,
我安装scala 2.10.0,播放2.1.0和IntelliJ12,
并创建一个播放项目,如下所示:

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

#news brew database
> cd $(brew --prefix)
> brew更新
> cd $(brew --prefix)&& git pull --rebase

#get scala 2.10.0
> brew版本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代码运行器版本2.10.0 - 版权所有2002-2012,LAMP / EPFL


#install play 2.1.0
> brew版本玩
2.1.0 git checkout 6a70797 Library / Formula / play.rb
...

> brew install play
>玩-version
玩! 2.1.0(使用Java 1.6.0_43和Scala 2.10.0),http://www.playframework.org

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

 > cd~ / 
>玩新的myapp
名称:myapp
创建一个简单的Scala应用程序

#generate IntelliJ项目:
> cd myapp
>玩
> idea
[info]创建/Users/david/myapp/.idea_modules/myapp.iml
[info]创建/Users/david/myapp/.idea_modules/myapp-build.iml

并在IntelliJ中打开项目:

  #Install IntelliJ 12 Ultimate Edition 
从http://www.jetbrains.com/idea/下载它b $ b 12.0.4,Build#IU-123.169
2月份建造13,2013

#在IntelliJ中安装scala插件
运行IntelliJ,
首选项 - >插件 - >从存储库浏览 - >添加scala。
当前版本:0.7.134

#在IntelliJ中打开myapp项目
文件 - >打开Project,选择目录/ Users / david / myapp

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

 项目 - > myapp  - >测试 - > ApplicationSpec  - > (右键单击) - >运行

我收到此错误:

  scala:未找到模块bigbrother的Сompiler库:右(项目)/右(scala-2.10.0)

实际上,有几个错误:

 在文件中 - >项目结构 - >模块,有两个模块:
-myapp
-mypp-build

文件 - >项目结构 - >模块 - > myapp - > Scala
编译器库:scala-2.10.0 [未找到]
<<<错误

文件 - >项目结构 - >模块 - > myapp-build - >依赖关系:
scala-2.9.2
<<<错误

如果我更正了第一个错误如下,

 文件 - >项目结构 - >模块 - > myapp  - > Scala  - >编译器库
并从下拉列表中选择第二个有效选项scala-2.10.0(版本2.10.0)。

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



'pre> 阶:输出路径/Users/david/bigbrother/project/target/scala_2.9.2之间共享:模块'bigbrother建造的生产,模块bigbrother建造'tests
目前,外部Scala编译器禁止输出路径共享。
禁用外部构建模式或配置单独的输出路径。
提示:您可以使用Project Artifacts来组合编译的类。

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






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



生成IntelliJ项目

 > cd myapp 
>玩
>想法no-sbt-build-module

(而不只是'想法')



然后,
项目设置 - >库
选择Scala 2.9.2并点击 - 将其删除。



然后,
项目设置 - >模块 - > my_app - > Scala - > Scala编译器
在此下拉列表中,选择Scala 2.10.0写成红色。
移到列表顶部,然后选择用黑色/灰色写的Scala 2.10.0(版本2.10.0)。






注意



有时(我不知道为什么)选择Scala 2.10.0(版本2.10) .0)以黑色/灰色书写在下拉列表中不可用。可供我使用的
a解决方法如下:
项目设置 - >全局库 - > + - > Java
选择这些文件scala-compiler.jar,scala-library。 jar和scala-reflect.jar来自这个目录:/usr/local/Cellar/scala/2.10.0/libexec/lib/
选择确定。
给它命名为my scala 2.10.0 bundle。



然后再转到Project Settings - > Module - > my_app - > Scala - > Scala编译器
现在你有两个,你刚刚创建的我的scala 2.10.0包,标准的一个:Scala 2.10.0(版本2.10.0)用黑色/灰色写的。选择标准的,删除你创建的全局库。



我不知道为什么会这样,我真的不想花更多的时间来找到这个出。目前,这种解决方法对我有用。但如果你发现,可以随意添加评论。

解决方案

这个问题可以通过生成想法项目来解决: / p>

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

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


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

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

I get this error:

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

Actually, there are several errors:

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?


Update: solution based on the answers from Marius and alexwriteshere

generate IntelliJ project with

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

(instead of just 'idea')

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

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.


Note

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".

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.

解决方案

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

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

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

10-30 14:48