Using Scala IDE on Maven projects

本文介绍如何在Eclipse中安装m2eclipse-scala插件,并通过该插件创建新的Scala Maven项目或导入现有Scala Maven项目的过程。教程涵盖了必要的配置步骤及常见问题解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

refer to :http://scala-ide.org/docs/tutorials/m2eclipse/index.html

Using Scala IDE for Eclipse on a Maven Scala project is fairly straightforward.. when all the pieces are in the right place. In this tutorial I will show how to use the Scala IDE on an existing maven project, and how to start with a fresh project.

Install m2eclipse-scala

Maven integration in Eclipse is a separate plugin, and depending on which version of Eclipse you have installed, you might already have it or not.

The default maven plugin does not support Scala out of the box, so you need to install the m2eclipse-scala connector. This connector understands the Scala maven plugin and links the compile phase to the Eclipse Scala Builder.

You can install both plugins by pointing Eclipse to the m2eclipse-scala update site.

Note

If you don't have the vanilla Maven Integration for Eclipse, make sure you have enabled Check all update sites to find required software. If you already have it, you can leave this box unchecked.

../../_images/install-new-software.png

In this tutorial we used the following versions:

  • Scala IDE: 3.0.0 for 2.10.1
  • m2eclipse: 1.3.1
  • m2eclipse-scala: 0.4.2
  • scala-maven-plugin: 3.1.3

Create a new Scala Maven project

If everything went well, you should now have Maven and Scala support in your Eclipse installation. Let's create a new Scala maven project, starting with a simple Scala project based on an archetype.

Select New -> Project -> Other and then select Maven Project. On the next window, search forscala-archetype. Make sure you select the one in group net.alchim31.maven, and click Next.

../../_images/archetypes.png

Follow the wizard and enter values for group ID, artifact, etc. Click Finish and you should have a new Scala project in the workspace.

../../_images/new-project.png

Notice that the new project has both the Maven and Scala nature, and src/main/scala is listed as a source folder. You should be able to build and launch your project, or run tests.

Import an existing Scala Maven project

It is probably rare to start a new project, so let's take a look at importing an existing Scala project.

Assuming your project builds fine with maven, you should have something similar in your pom.xml:

    
  1. <plugin>
  2. <groupId>net.alchim31.maven</groupId>
  3. <artifactId>scala-maven-plugin</artifactId>
  4. <version>3.1.3</version>
  5. <executions>
  6. <execution>
  7. <goals>
  8. <goal>compile</goal>
  9. <goal>testCompile</goal>
  10. </goals>
  11. </execution>
  12. </executions>

To get this project in Eclipse, choose File -> Import -> Existing Maven Project and navigate to the directory containing your maven project.

../../_images/import.png

When you click Finish, the project is imported and it should have both Maven and Scala natures. You'll notice that both src/main/java and src/main/scala are listed as source folders. You should be able to build and run your application, and use all Maven commands on your project.

Warning

As of March 2013, a bug causes both src/main/scala and src/test/scala to use the default output folder (target/classes). This may be confusing when building tests, since their class files will not end in target/test-classes, as they would when building on the command line. You can work around this by manually changing the output folder for src/test/scala.

lvzhuoyuan@U-VF56K71F-1930 lindormML % mvn javadoc:javadoc # 单独执行插件目标 [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Detecting the operating system and CPU architecture [INFO] ------------------------------------------------------------------------ [INFO] os.detected.name: osx [INFO] os.detected.arch: x86_64 [INFO] os.detected.bitness: 64 [INFO] os.detected.version: 10.16 [INFO] os.detected.version.major: 10 [INFO] os.detected.version.minor: 16 [INFO] os.detected.classifier: osx-x86_64 [INFO] ------------------------------------------------------------------------ [INFO] Detecting the operating system and CPU architecture [INFO] ------------------------------------------------------------------------ [INFO] os.detected.name: osx [INFO] os.detected.arch: x86_64 [INFO] os.detected.version: 10.16 [INFO] os.detected.version.major: 10 [INFO] os.detected.version.minor: 16 [INFO] os.detected.classifier: osx-x86_64 [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] Lindorm ML Project [pom] [INFO] ldml-sql [jar] [INFO] ldml-inference-client [jar] [INFO] ldml-core [jar] [INFO] ldml-jdbc [jar] [INFO] ldml-train [jar] [INFO] ldml-inference [jar] [INFO] ldml-exec [jar] [INFO] ldml-server [jar] [INFO] ldml-endpoint-lsql [jar] [INFO] dist-ldml-server [pom] Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-enforcer-plugin/3.1.0/maven-enforcer-plugin-3.1.0.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-enforcer-plugin/3.1.0/maven-enforcer-plugin-3.1.0.pom (7.2 kB at 35 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/enforcer/enforcer/3.1.0/enforcer-3.1.0.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/enforcer/enforcer/3.1.0/enforcer-3.1.0.pom (8.3 kB at 101 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-enforcer-plugin/3.1.0/maven-enforcer-plugin-3.1.0.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-enforcer-plugin/3.1.0/maven-enforcer-plugin-3.1.0.jar (26 kB at 231 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/net/alchim31/maven/scala-maven-plugin/4.5.3/scala-maven-plugin-4.5.3.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/net/alchim31/maven/scala-maven-plugin/4.5.3/scala-maven-plugin-4.5.3.pom (24 kB at 152 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/net/alchim31/maven/scala-maven-plugin/4.5.3/scala-maven-plugin-4.5.3.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/net/alchim31/maven/scala-maven-plugin/4.5.3/scala-maven-plugin-4.5.3.jar (136 kB at 1.2 MB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/gmavenplus/gmavenplus-plugin/1.2/gmavenplus-plugin-1.2.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/gmavenplus/gmavenplus-plugin/1.2/gmavenplus-plugin-1.2.pom (23 kB at 297 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/codehaus-parent/4/codehaus-parent-4.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/codehaus-parent/4/codehaus-parent-4.pom (4.8 kB at 62 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/gmavenplus/gmavenplus-plugin/1.2/gmavenplus-plugin-1.2.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/gmavenplus/gmavenplus-plugin/1.2/gmavenplus-plugin-1.2.jar (88 kB at 1.1 MB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/net/bytebuddy/byte-buddy-maven-plugin/1.12.9/byte-buddy-maven-plugin-1.12.9.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/net/bytebuddy/byte-buddy-maven-plugin/1.12.9/byte-buddy-maven-plugin-1.12.9.pom (4.7 kB at 57 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/net/bytebuddy/byte-buddy-maven-plugin/1.12.9/byte-buddy-maven-plugin-1.12.9.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/net/bytebuddy/byte-buddy-maven-plugin/1.12.9/byte-buddy-maven-plugin-1.12.9.jar (44 kB at 514 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-release-plugin/3.0.0-M7/maven-release-plugin-3.0.0-M7.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-release-plugin/3.0.0-M7/maven-release-plugin-3.0.0-M7.pom (9.4 kB at 110 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/release/maven-release/3.0.0-M7/maven-release-3.0.0-M7.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/release/maven-release/3.0.0-M7/maven-release-3.0.0-M7.pom (11 kB at 144 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-release-plugin/3.0.0-M7/maven-release-plugin-3.0.0-M7.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-release-plugin/3.0.0-M7/maven-release-plugin-3.0.0-M7.jar (61 kB at 704 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/mojo/build-helper-maven-plugin/3.3.0/build-helper-maven-plugin-3.3.0.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/mojo/build-helper-maven-plugin/3.3.0/build-helper-maven-plugin-3.3.0.pom (7.4 kB at 93 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/mojo/mojo-parent/65/mojo-parent-65.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/mojo/mojo-parent/65/mojo-parent-65.pom (35 kB at 413 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/mojo/build-helper-maven-plugin/3.3.0/build-helper-maven-plugin-3.3.0.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/mojo/build-helper-maven-plugin/3.3.0/build-helper-maven-plugin-3.3.0.jar (68 kB at 786 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/moditect/moditect-maven-plugin/1.0.0.RC2/moditect-maven-plugin-1.0.0.RC2.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/moditect/moditect-maven-plugin/1.0.0.RC2/moditect-maven-plugin-1.0.0.RC2.pom (4.0 kB at 48 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/moditect/moditect-parent/1.0.0.RC2/moditect-parent-1.0.0.RC2.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/moditect/moditect-parent/1.0.0.RC2/moditect-parent-1.0.0.RC2.pom (7.3 kB at 94 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/moditect/moditect-org-parent/1.0.0.Final/moditect-org-parent-1.0.0.Final.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/moditect/moditect-org-parent/1.0.0.Final/moditect-org-parent-1.0.0.Final.pom (18 kB at 206 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/moditect/moditect-maven-plugin/1.0.0.RC2/moditect-maven-plugin-1.0.0.RC2.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/moditect/moditect-maven-plugin/1.0.0.RC2/moditect-maven-plugin-1.0.0.RC2.jar (46 kB at 235 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-project-info-reports-plugin/3.1.2/maven-project-info-reports-plugin-3.1.2.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-project-info-reports-plugin/3.1.2/maven-project-info-reports-plugin-3.1.2.pom (19 kB at 99 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-project-info-reports-plugin/3.1.2/maven-project-info-reports-plugin-3.1.2.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-project-info-reports-plugin/3.1.2/maven-project-info-reports-plugin-3.1.2.jar (293 kB at 2.2 MB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-changelog-plugin/2.3/maven-changelog-plugin-2.3.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-changelog-plugin/2.3/maven-changelog-plugin-2.3.pom (14 kB at 172 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-changelog-plugin/2.3/maven-changelog-plugin-2.3.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-changelog-plugin/2.3/maven-changelog-plugin-2.3.jar (59 kB at 736 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-changes-plugin/2.10/maven-changes-plugin-2.10.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-changes-plugin/2.10/maven-changes-plugin-2.10.pom (20 kB at 90 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-changes-plugin/2.10/maven-changes-plugin-2.10.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-changes-plugin/2.10/maven-changes-plugin-2.10.jar (213 kB at 843 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-source-plugin/3.2.1/maven-source-plugin-3.2.1.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-source-plugin/3.2.1/maven-source-plugin-3.2.1.pom (6.9 kB at 89 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-source-plugin/3.2.1/maven-source-plugin-3.2.1.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-source-plugin/3.2.1/maven-source-plugin-3.2.1.jar (32 kB at 370 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-javadoc-plugin/3.3.0/maven-javadoc-plugin-3.3.0.pom Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-javadoc-plugin/3.3.0/maven-javadoc-plugin-3.3.0.pom (21 kB at 260 kB/s) Downloading from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-javadoc-plugin/3.3.0/maven-javadoc-plugin-3.3.0.jar Downloaded from alibaba-releases: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/plugins/maven-javadoc-plugin/3.3.0/maven-javadoc-plugin-3.3.0.jar (515 kB at 2.7 MB/s) [INFO] [INFO] --------------< com.alibaba.lindorm.sqlminds:lindorm-ml >--------------- [INFO] Building Lindorm ML Project 1.3.4.2 [1/11] [INFO] --------------------------------[ pom ]--------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Lindorm ML Project 1.3.4.2: [INFO] [INFO] Lindorm ML Project ................................. FAILURE [ 0.002 s] [INFO] ldml-sql ........................................... SKIPPED [INFO] ldml-inference-client .............................. SKIPPED [INFO] ldml-core .......................................... SKIPPED [INFO] ldml-jdbc .......................................... SKIPPED [INFO] ldml-train ......................................... SKIPPED [INFO] ldml-inference ..................................... SKIPPED [INFO] ldml-exec .......................................... SKIPPED [INFO] ldml-server ........................................ SKIPPED [INFO] ldml-endpoint-lsql ................................. SKIPPED [INFO] dist-ldml-server ................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.009 s [INFO] Finished at: 2025-06-23T20:16:51+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Unknown lifecycle phase "#". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException lvzhuoyuan@U-VF56K71F-1930 lindormML % 不对啊
最新发布
06-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值