Eclipse、Scala 和 Maven - 未生成类文件

2024-02-22

我在 Eclipse 中将我的 scala 项目转换为使用 Maven(只需右键单击项目并配置 Maven 构建),这创建了 pom.xml,添加了正确的依赖项,从 Maven 存储库中提取所需的 jar,但每当我尝试编译时,我不会请参阅 target\classes 文件夹中生成的类文件。但是,我看到实际的源代码是 target\classes 文件夹下相应目录中的 scala 文件。我不确定为什么它要复制 target\classes 文件夹中的源文件。

另一个奇怪的事情是,如果我在 Eclipse 中打开单个 scala 文件并进行一些代码更改,那么它会自动构建该类文件,但是我有 1000 多个 scala 文件,所以不是一个可行的选择。

我尝试了所有选项,例如 Eclipse - Clean & Build,但没有任何效果,我什至尝试在 Eclipse 内使用 maven build,但它总是出现此消息“没有要编译的内容 - 所有类都是最新的”,我清理了我的目标目录,但仍然是一个问题。

我将不胜感激在这方面的任何帮助。

提前致谢

我正在使用 Scala Eclipse IDE -Eclipse SDK 的 Scala IDE 构建 内部版本号:3.0.4-2.11-20140520-1158-Typesafe

Content of Pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>notmaven</groupId>
  <artifactId>notmaven</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <sourceDirectory>C:\projectsomu\notmaven\src</sourceDirectory>
    <scriptSourceDirectory>C:\projectsomu\notmaven\src\main\scripts</scriptSourceDirectory>
    <testSourceDirectory>C:\projectsomu\notmaven\src\test\java</testSourceDirectory>
    <outputDirectory>C:\projectsomu\notmaven\target\classes</outputDirectory>
    <testOutputDirectory>C:\projectsomu\notmaven\target\test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>C:\projectsomu\notmaven\src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>C:\projectsomu\notmaven\src\test\resources</directory>
      </testResource>
    </testResources>
    <directory>C:\projectsomu\notmaven\target</directory>
    <finalName>notmaven-0.0.1-SNAPSHOT</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <executions>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <source>1.3</source>
              <target>1.2</target>
            </configuration>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <source>1.3</source>
              <target>1.2</target>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <source>1.3</source>
          <target>1.2</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.4.1</version>
        <executions>
          <execution>
            <id>default-clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
          <execution>
            <id>default-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.3.2</version>
        <executions>
          <execution>
            <id>default-jar</id>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.10</version>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
          <execution>
            <id>default-install</id>
            <phase>install</phase>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.0</version>
        <executions>
          <execution>
            <id>default-site</id>
            <phase>site</phase>
            <goals>
              <goal>site</goal>
            </goals>
            <configuration>
              <outputDirectory>C:\projectsomu\notmaven\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
          <execution>
            <id>default-deploy</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
            <configuration>
              <outputDirectory>C:\projectsomu\notmaven\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <outputDirectory>C:\projectsomu\notmaven\target\site</outputDirectory>
          <reportPlugins>
            <reportPlugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
            </reportPlugin>
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <outputDirectory>C:\projectsomu\notmaven\target\site</outputDirectory>
  </reporting>
</project>

You 应该添加 http://scala-ide.org/docs/tutorials/m2eclipse/#Import_an_existing_Scala_Maven_project将以下插件添加到您的 Maven 配置中(pom.xml)并重新配置项目。

<plugin>
  <groupId>net.alchim31.maven</groupId>
  <artifactId>scala-maven-plugin</artifactId>
  <version>3.1.3</version>
  <executions>
    <execution>
      <goals>
        <goal>compile</goal>
        <goal>testCompile</goal>
      </goals>
    </execution>
  </executions>
</plugin>

You 还应该添加 http://scala-ide.org/docs/tutorials/m2eclipse/#Install_m2eclipse-scalam2e-scala 插件来自其更新站点 http://alchim31.free.fr/m2e-scala/update-site.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Eclipse、Scala 和 Maven - 未生成类文件 的相关文章

  • 如何通过 javascript 和 ajax 调用 Scala 中的方法?

    我不知道我的标题是否有点误导 但这是我真正需要帮助的 我正在获取这个网址 get fb login fbEmail function data console log data 这是我的路线 GET fb login email prese
  • 为什么自类型类可以声明类

    我知道 Scala 只能混合特征 这对于依赖注入和蛋糕模式是有意义的 我的问题是为什么我仍然可以声明一个需要另一个 类 但不需要特征的类 Code class C class D self C gt 这仍然编译成功 我认为它应该编译失败 因
  • 适用于 C/C++ 和 Java 的 Eclipse IDE

    我正在尝试在运行 El Capitan 的 Mac 上设置 Java IDE 但是我找到的安装程序要求我为 C C 和 Java 安装单独的 IDE Eclipse Neon Eclipse 有什么选项可以让我拥有一个支持多种语言的 IDE
  • 如何在 sbt 控制台中加载 scala 文件? [复制]

    这个问题在这里已经有答案了 可能的重复 将 Scala 文件加载到解释器中以使用函数 https stackoverflow com questions 7383436 load scala file into interpreter to
  • Android SDK 管理器不工作

    启动 Eclipse 时我收到一条消息 This version of ADT requires Android SDK Tools revision 21 0 0 rc9 or above Current version is 10 0
  • 获取SettingKey[T]的值

    我正在开发一个用于文档生成的插件 我想将所有生成的文件输出到我选择的目录中 该目录可以是SBT的子目录target目录 如下 val newTargetDirectory SettingKey File document target di
  • 使用 CounterClockwise 和 Eclipse 在 Clojure REPL 中进行评估

    我通常使用 Emacs 但受到启发再次尝试 CCW Eclipse 我有一个 Clojure 测试项目 其源文件 src user clj 包含以下内容 ns user println hi 我有一个 REPL 我从 Window gt S
  • Scala 使用的 Redis 客户端库建议

    我正在计划使用 Scala 中的 Redis 实例进行一些工作 并正在寻找有关使用哪些客户端库的建议 理想情况下 如果存在一个好的库 我希望有一个为 Scala 而不是 Java 设计的库 但如果现在这是更好的方法 那么仅使用 Java 客
  • 如何正确使用“mvn release:prepare”?

    我尝试了这个命令 用dryrun在我的 Maven 项目上进行测试 mvn release clean release prepare DdryRun true DgenerateBackupPoms false Dtag solocal
  • 为什么这些类型参数不符合类型细化?

    为什么此 Scala 代码无法进行类型检查 trait T type A trait GenFoo A0 S lt T type A A0 trait Foo S lt T extends GenFoo S A S 我不明白为什么 类型参数
  • scala 返回列表中的第一个 Some

    我有一个清单l List T1 目前我正在执行以下操作 myfun T1 gt Option T2 val x Option T2 l map myfun l flatten find gt true The myfun函数返回 None
  • 如何在 Scala 2.11 中查找封闭源文件的名称

    在编译时 如何在 scala 2 11 中检索当前源文件 编写代码的位置 的名称 这是一种实际有效的方法 val srcFile new Exception getStackTrace head getFileName println sr
  • Scala 和 Python 的通行证

    我想知道 是否有相当于 python 的 pass 表达式 这个想法是编写没有实现的方法签名 并编译它们只是为了对某些库原型的这些签名进行类型检查 我能够使用以下方法模拟这种行为 def pass A A throw new Excepti
  • Android ADT Eclipse 插件,parseSDKContent 失败

    我刚刚设置了我的第一个 Android 开发环境 其中包括 日食3 5 Mac OS X 10 5 适用于 x86 mac 的 Android SDK ADT Eclipse 插件 0 9 6 我已将 set PATH 设置为我的 SDK
  • IntelliJ IDEA 能否正确格式化 scala.html 文件以及如何启用它?

    IntelliJ IDEA 12 Ultimate 和 CE 格式化我的 main scala html 文件中的以下行 在 Play 应用程序中 main css gt As main css gt 是的 真的 它分解了带引号的字符串 我
  • 如何在 Lift 框架中添加新页面

    如何在 lift 中的 webapp 目录中添加一个可供用户访问的新页面 目前只能通过index html访问http localhost 8080 com http localhost 8080 or http localhost 808
  • 将过滤器添加到 Eclipse 中的 Project Explorer

    我想向 Project Explorer 添加一个新的过滤器 以向用户隐藏一些在 Eclipse RCP 应用程序中自动创建的项目 到目前为止我已经找到了两个扩展点 org eclipse ui ide resourceFilters 允许
  • 未解决的包含:“cocos2d.h” - Cocos2dx

    当我在 Eclipse 中导入 cocos2dx android 项目时 我的头文件上收到此警告 Unresolved inclusion cocos2d h 为什么是这样 它实际上困扰着我 该项目可以正确编译并运行 但我希望这种情况消失
  • ECMASCRIPT 5 与 wro4j 和 Google Closure 编译器

    我们将 wro4j 与 Google Closure 和 Maven 一起使用来缩小我们的 JS 默认情况下 它不支持 JS 中的严格模式 use strict 它只是将其删除 有什么配置我可以做吗pom xml或其他地方让它离开use s
  • 了解 Spark 中的 DAG

    问题是我有以下 DAG 我认为当需要洗牌时 火花将工作划分为不同的阶段 考虑阶段 0 和阶段 1 有些操作不需要洗牌 那么为什么 Spark 将它们分成不同的阶段呢 我认为跨分区的实际数据移动应该发生在第 2 阶段 因为这里我们需要cogr

随机推荐