如何在Eclipse中找到使用Scala开发的正确的Maven原型项目? [英] How do I find the correct Maven archetype project for developing with Scala in Eclipse?

查看:278
本文介绍了如何在Eclipse中找到使用Scala开发的正确的Maven原型项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Eclipse(Luna)中的Scala(v2.11.6)创建一个Maven项目。

  • 说明:远程原型


  • 返回创建一个新的Maven项目。从下拉列表中选择远程目录。收集所有的原型将需要一些时间。您可以在IDE的右下方看到进度。完成之后,您应该可以看到原型







    中显示scala-archetype条目的图像创建您的项目groupId和artifactId等等。



    右键单击项目,然后从上下文菜单[运行方式]& rarr [Maven Build]。在对话框中,键入 clean package 到目标。运行。该项目应该构建并运行测试。



    对于我起初我在构建上有错误。这是因为我的默认环境是使用Java 8.我对Scala很新,所以我不知道Scala和Java 8有没有问题(我认为这是Scom中的Scala版本(2.10。 0))。但是我所做的只是将IDE中使用的Java版本更改为Java 7。



    基本上只需转到[Windows]和rarr; [Preferenes]→ [Java]→ [安装JRE]→ 添加→ [系统虚拟机]→ 下一页→目录→找到Java Home(第7版)的目录→ 完成→然后在列表中勾选Java 7。



    然后再次构建。应该工作祝你好运!


    I'm having problems trying to just create a Maven project using Scala (v2.11.6) within Eclipse (Luna). The instructions here says to install both plugins below.

    • Maven Integration in Eclipse
    • m2eclipse-scala connector

    Both plugins can be installed by using the m2eclipse-scala update site. So here's what I did in my first attempt.

    • Download Eclipse Luna (for JavaEE developers)
    • Install "both" plugins above by using the m2eclipse-scala update site.

    When Eclipse loads up, I attempt to create a Maven project, and the archetype I want to use is Group Id=net.alchim31.maven, Artifact Id=scala-archetype-simple, Version=1.5. However, this archetype never shows up when I enter in "scala-arch" in the filter text field.

    The only project I see is the one with Group Id=org.scala-tools.archetypes, Artifact Id=scala-archetype-simple, Version=1.2. When I select this archetype to use, I get a bunch of error messages in Eclipse.

    • error while loading ConsoleRunner, Scala signature ConsoleRunner has wrong version expected: 5.0 found: 4.1 in ConsoleRunner.class
    • error while loading JUnit4, Scala signature JUnit4 has wrong version expected: 5.0 found: 4.1 in JUnit4.class
    • error while loading Specification, Scala signature Specification has wrong version expected: 5.0 found: 4.1 in Specification.class

    In my second attempt, I try to download the pre-packaged bundle (Scala IDE for Eclipse). Again, when I attempt to create a Scala Maven project, I don't see the Maven archetype for Group Id=net.alchim31.maven (only for Group Id=org.scala-tools.archetypes).

    Any ideas on what I'm doing wrong here? Or where I can find a vanilla Scala Maven project to import/modify and use for my own purpose?

    解决方案

    Here's how I got it to work. It seems all the archetypes aren't available, so based on this answer, I created a remote catalog

    Before

    So do this

    Go to [Windows] → [Preferences] → [Maven] → [Archetypes] → Add Remote Catalog and create the catalog, then Apply

    For copy-pasting:

    Go back to creating a new Maven project. Select the Remote Catalog from the dropdown. It will take a few moments to gather all the archetypes. You can see the progress at the very bottom right of the IDE. When it's done, you should be able to see the archetypes

    After

    Create your project with groupId and artifactId and such.

    Right click the project, then from the context menu [Run As] &rarr [Maven Build]. In the dialog, type clean package into the goals. The run. The project should build and run the tests.

    For me at first I got an error on the build. It was because my default environment is using Java 8. I'm pretty new to Scala, so I'm not sure is there is a problem with Scala and Java 8 or not (I think it's the Scala version in the pom (2.10.0)). But what I did to get it to work was just change the Java version used in the IDE to Java 7.

    Basically just go to [Windows] → [Preferenes] → [Java] → [Installed JREs] → Add → [System VM] → Next → Directory → Find the directory of the Java home (version 7) → Finish → Then in the list tick Java 7.

    Then build again. It should work. Good Luck!

    这篇关于如何在Eclipse中找到使用Scala开发的正确的Maven原型项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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