【问题标题】:NetBeans + Scala + MavenNetBeans + Scala + Maven
【发布时间】:2012-11-12 00:49:44
【问题描述】:

我是 Scala 新手,对 Java 比较陌生。我似乎无法在 Scala 中使用 IDE。我正在使用纯文本编辑器并使用 sbt,效果很好。但我想要代码提示,让 IDE 通过在 maven 中搜索类来帮助我解析类。

我有用于 NetBeans 的 Scala 插件,但它使用 ant。代码提示有效,但它不像使用 java/maven 那样为我解析类。

有没有办法通过 Maven 或 SBT 将 NetBeans 与 Scala 结合使用?

【问题讨论】:

    标签: scala maven netbeans sbt


    【解决方案1】:

    我不是 NetBeans 用户,但我想使用 maven 设置对其进行测试,对我来说,它与以下 pom 文件配合良好。

    它使用ScalaTest 进行单元测试。

    我刚刚通过选择Open project... 加载了这个项目并指向了 pom 文件。

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.stackoverflow.Q13337089</groupId>
        <artifactId>scala</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <name>${project.artifactId}-${project.version}</name>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <scala.version>2.9.2</scala.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.scala-lang</groupId>
                <artifactId>scala-library</artifactId>
                <version>${scala.version}</version>
            </dependency>
            <dependency>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest_2.9.2</artifactId>
                <version>2.0.M4</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.scala-tools</groupId>
                    <artifactId>maven-scala-plugin</artifactId>
                    <version>2.15.2</version>
                    <executions>
                        <execution>
                            <id>scala-compile</id>
                            <goals>
                                <goal>compile</goal>
                                <goal>testCompile</goal>
                            </goals>
                            <configuration>
                                <args>
                                    <arg>-make:transitive</arg>
                                    <arg>-dependencyfile</arg>
                                    <arg>${project.build.directory}/.scala_dependencies</arg>
                                </args>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.7.2</version>
                    <executions>
                        <execution>
                            <id>default-test</id>
                            <!-- Disable the default-test by putting it in phase none -->
                            <phase>none</phase>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest-maven-plugin</artifactId>
                    <version>1.0-M2</version>
                    <configuration>
                        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                        <junitxml>.</junitxml>
                        <filereports>WDF TestSuite.txt</filereports>
                        <stdout>W</stdout> <!-- Skip coloring output -->
                    </configuration>
                    <executions>
                        <execution>
                            <id>scala-test</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
    

    【讨论】:

    • 我有一个类似的文件,但我没有看到任何代码完成并且运行文件不起作用。运行项目有时有效,否则我会得到 NoClassDefFoundError。 netbeansmaven 你有运气吗?
    【解决方案2】:

    https://github.com/dcaoyuan/nbscala#readme 应该在某些实例中包含将 scala 支持与 maven 项目桥接的代码。 netbeans 模块在源代码中,不确定它是否是二进制文件。

    【讨论】:

      【解决方案3】:

      这对我有用。 首先安装netbeans > 7.4 第二netbeans plugins website安装scala插件按照说明添加插件。 第三创建一个 Maven 项目。新项目-> Maven-> 来自原型的项目。然后选择“scala archetype simple”,然后选择“Next”和“finish”。

      【讨论】:

        【解决方案4】:

        我在 Scala IDE 和 eclipse 上玩得更好。如果您只是想启动一个项目,那么这确实是您所需要的。

        现在还有一个用于 eclipse 的 sbt 插件(虽然我没有使用它,因为 sbt 的 eclipse 插件可以很好地生成 eclipse 项目文件)。

        如果您想从 sbt 构建文件进入 eclipse,那么我可以告诉您,我使用 Lift 进行 webapp 开发(从 sbt 构建模板开始),并且我根据这些说明进行了设置,其中包括集成它进入日食:

        http://scala-ide.org/docs/tutorials/lift24scalaide20/index.html

        实际上,top-level tutorials 目录包含使用 Scala IDE 进行 Play、Android 开发和其他操作的说明。

        【讨论】:

          猜你喜欢
          • 2011-05-16
          • 1970-01-01
          • 2021-07-09
          • 2011-10-29
          • 2013-10-10
          • 1970-01-01
          • 1970-01-01
          • 2018-02-01
          • 2014-06-21
          相关资源
          最近更新 更多