关于stackoverflow:maven-混合编译-scala-代码报错qbit

41次阅读

共计 1907 个字符,预计需要花费 5 分钟才能阅读完成。

前言

  • 技术栈

    Windows  10
    Java/JDK 1.8.0_202
    Maven    3.6.3
    spark    2.4.6
    scala    2.12
    hadoop   2.6.0-cdh5.10.0
  • 操作系统中并没有装置 scala,利用 pom.xml 中的插件编译 scala 代码

报错景象

  • 编译命令

    mvn -D maven.test.skip=true clean scala:compile compile package
  • 报如下谬误

    ......
    [ERROR] error: java.lang.StackOverflowError
    ......
    [INFO]  at scala.tools.nsc.javac.JavaScanners$JavaScanner.skipBlockComment(JavaScanners.scala:585)
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  12.495 s
    [INFO] Finished at: 2023-03-20T13:56:52+08:00
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.4.6:compile (default-cli) on project DataAnalysis_aws_smartlib: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: -10000 (Exit value: -10000) -> [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/MojoExecutionException

解决办法

  • 给编译插件增加 jvm 参数 jvmArg,增加后 scala-maven-plugin 插件残缺配置如下

    <plugin>
      <groupId>net.alchim31.maven</groupId>
      <artifactId>scala-maven-plugin</artifactId>
      <version>3.4.6</version>
      <executions>
          <execution>
              <id>scala-compile-first</id>
              <phase>process-resources</phase>
              <goals>
                  <goal>add-source</goal>
                  <goal>compile</goal>
              </goals>
          </execution>
      </executions>
      <configuration>
          <jvmArgs>
              <!-- 指定 scala 编译时栈大小 -->
              <jvmArg>-Xss4m</jvmArg>
          </jvmArgs>
          <scalaVersion>${scala.version}</scalaVersion>
      </configuration>
    </plugin>
  • scala-maven-plugin 插件 GitHub 地址:https://github.com/davidB/scala-maven-plugin

相干浏览

  • JVM 参数及默认值

    -Xms
    指定 jvm 堆的初始大小,默认为物理内存的 1 /64,最小为 1M;能够指定单位,比方 k、m,若不指定,则默认为字节。-Xmx
    指定 jvm 堆的最大值,默认为物理内存的 1 / 4 或者 1G,最小为 2M;单位与 -Xms 统一。-Xss
    设置单个线程栈的大小,个别默认为 512k。

本文出自 qbit snap

正文完
 0