在IDEA中升级Maven项目中的Scala版本

发布于 2024-12-05 14:26:48 字数 2115 浏览 1 评论 0原文

我使用 IDEA 10.5.2 和 Scala 插件版本 0.4.1395 以及 IDE 附带的标准 Maven 集成插件。我有一个具有上述设置的 Scala 2.8.0 项目,我想将其升级到 Scala 2.9.1。我对 pom.xml 进行了必要的更改。以下是我的 pom.xml 中的相关部分:

插件部分:

  <plugin>
    <groupId>org.scala-tools</groupId>
    <artifactId>maven-scala-plugin</artifactId>
    <executions>
      <execution>
        <id>compile</id>
        <goals>
          <goal>compile</goal>
        </goals>
        <phase>compile</phase>
      </execution>
      <execution>
        <id>test-compile</id>
        <goals>
          <goal>testCompile</goal>
        </goals>
        <phase>test-compile</phase>
      </execution>
      <execution>
        <phase>process-resources</phase>
        <goals>
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
  </plugin> 

依赖项部分:

<dependency>
  <groupId>org.scala-lang</groupId>
  <artifactId>scala-compiler</artifactId>
  <version>2.9.1</version>
</dependency>
<dependency>
  <groupId>org.scala-lang</groupId>
  <artifactId>scala-library</artifactId>
  <version>2.9.1</version>
</dependency>

我的计算机上安装了 Scala 2.9.1。

在我的项目设置中,在 Scala 方面,编译器实例化部分有几个“编译器库”选项。然而,我的项目并不是建立在选择其中任何一个的基础上的。

当我选择 Maven: org.scala-lang:scala-compiler-bundle:2.9.1 时,出现以下错误:

无法编译 Scala 文件。
请调整Scala方面的编译器库:无法读取scala-library-2.9.1.jar版本。

当我选择 Maven: org.scala-lang:scala-compiler:2.9.1 时,出现以下错误:

无法编译 Scala 文件。
请调整 Scala 方面的编译器库:未找到 scala-library*.jar。

当我选择 Maven: org.scala-lang:scala-library:2.9.1 时,出现以下错误:

无法编译 Scala 文件。
请调整 Scala 方面的编译器库:未找到 scala-compiler*.jar。

我做错了什么?我应该怎么做才能构建我的项目?

请注意,我是第一次使用构建工具。任何帮助将不胜感激。谢谢!

I am using IDEA 10.5.2 with Scala plugin version 0.4.1395 and the standard Maven integration plugin that ships with the IDE. I have a Scala 2.8.0 project with the above setting, and I want to upgrade it to Scala 2.9.1. I made the necessary changes to pom.xml. Here are the relevant sections from my pom.xml:

Plugin section:

  <plugin>
    <groupId>org.scala-tools</groupId>
    <artifactId>maven-scala-plugin</artifactId>
    <executions>
      <execution>
        <id>compile</id>
        <goals>
          <goal>compile</goal>
        </goals>
        <phase>compile</phase>
      </execution>
      <execution>
        <id>test-compile</id>
        <goals>
          <goal>testCompile</goal>
        </goals>
        <phase>test-compile</phase>
      </execution>
      <execution>
        <phase>process-resources</phase>
        <goals>
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
  </plugin> 

Dependencies section:

<dependency>
  <groupId>org.scala-lang</groupId>
  <artifactId>scala-compiler</artifactId>
  <version>2.9.1</version>
</dependency>
<dependency>
  <groupId>org.scala-lang</groupId>
  <artifactId>scala-library</artifactId>
  <version>2.9.1</version>
</dependency>

I have Scala 2.9.1 installed on my machine.

In my project settings, in the Scala facet, the compiler instantiation section has several options for "compiler library". However my project doesn't build on selecting any of them.

When I select Maven: org.scala-lang:scala-compiler-bundle:2.9.1, I get the following error:

Cannot compile Scala files.
Please, adjust compiler library in Scala facet: unable to read scala-library-2.9.1.jar version.

When I select Maven: org.scala-lang:scala-compiler:2.9.1, I get the following error:

Cannot compile Scala files.
Please, adjust compiler library in Scala facet: no scala-library*.jar found.

When I select Maven: org.scala-lang:scala-library:2.9.1, I get the following error:

Cannot compile Scala files.
Please, adjust compiler library in Scala facet: no scala-compiler*.jar found.

What am I doing wrong? What should I do to get my project build?

Please note that I am using a build tool for the first time. Any help would be greatly appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一向肩并 2024-12-12 14:26:48

如果您正在 IDEA 中使用 Maven 项目,则更改 Scala 版本通常非常容易。

首先,您必须确保 IDEA 使用您的 Maven 项目配置。您可以通过右键单击 pom.xml 来检查这一点。如果您看到菜单条目“添加为 Maven 项目”(或类似内容),请单击它。否则,您应该会看到一个名为“Maven”的子菜单,这意味着您的 Maven 项目已经正确配置。

现在你可以在 pom.xml 中更改 Scala 版本,IDEA 应该立即下载相应的包并在项目设置中更改 Scala 编译器(如果你启用了 pom 文件的自动导入)。否则IDEA会弹出一条消息,允许您手动执行pom文件导入。

但是,我没有使用 Scala 插件 0.4.1395 测试此工作流程,因为我在使用此插件版本时遇到了一些问题。我最终回到了 0.4.1385 版本,我认为它非常稳定。如果您的 Scala 插件有任何问题,我也建议您这样做。

If you are working with a maven project in IDEA changing the Scala version is usually very easy.

First you have to make sure that IDEA is using your maven project configuration. You can check this by right-clicking on the pom.xml. If you see a menu entry "Add as maven project" (or something similar) click on it. Otherwise you should see a sub menu called "Maven" which means that your maven project is already configured properly.

Now you can change the Scala version in your pom.xml and IDEA should immediately download the corresponding packages and change the Scala compiler in project settings (if you have auto-import of pom files enabled). Otherwise IDEA pop up a message allowing you to perform the pom file import manually.

However, I did not test this workflow with the Scala plugin 0.4.1395, because I had some troubles with this plugin version. I finally went back to version 0.4.1385 which is IMO very stable. If you have any troubles with your Scala plugin I suggest you the same.

赢得她心 2024-12-12 14:26:48

您肯定想使用“bundle”库。这似乎是 IDEA 专门为此设置创建的。也许您拥有的其中一个罐子已损坏?我会尝试从本地 Maven 存储库中删除所有内容,然后让 Maven 再次下载所有内容。

You definitely want to be using the "bundle" library. That seems to be created by IDEA specifically for this setting. Maybe one of the jars that you have is corrupt? I'd try removing everything from your local Maven repository and letting Maven download it all again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文