Intellij: SBT-based Scala project does not build with Java 9

前端 未结 4 927
离开以前
离开以前 2020-12-15 08:56

I\'ve tried to switch my Scala/sbt based project to Java 9. If I compile the project with sbt, it works.

If I try to build the project with the Build option of Intel

相关标签:
4条回答
  • 2020-12-15 09:15
    1. Open [File -> Settings -> Build, Execution, Deployment -> Compiler]
    2. Add "--add-modules java.se.ee" to [Shared build process VM options]
    0 讨论(0)
  • 2020-12-15 09:18

    Moving this as an answer to serve as a temporary suggestion unless there is a definite solution to it and to club together few other points.

    Seems like scala is not yet complete in terms of readiness to be used with JDK-9 as visible at scala/scala-dev - Support JDK 9


    On the other hand, the way of solving the dependency on the javax.xml.bind could be currently categorized into two categories:-

    • Your project uses a library which in turn requires javax.xml.bind, in which case there is not much in your hands other than waiting for that library to move to a modular structure prior to your restructuring. However, this can then be temporarily hacked by the --add-modules javax.xml.bind option provided as the compiler argument.

    • Your project makes use of the javax.xml.bind directly. In which case the ideal solution is to move away from the module and make use of the dependency[jaxb-api:2.3.0] and refactor code accordingly.

    0 讨论(0)
  • 2020-12-15 09:21

    In addition to @nullpointer answer, short instruction how to use --add-modules

    Open File -> Settings -> Build, Execution, Deployment -> Compiler, and add --add-modules java.xml.bind to Shared build process VM options

    0 讨论(0)
  • 2020-12-15 09:31

    In addition to the above answers.

    If you are not using IntelliJ and running the program from sbt console, I found the following resolved the issue:

    • Adding the following to your build.sbt:

      libraryDependencies += "javax.xml.bind" % "jaxb-api" % "2.3.0"

    • Adding the import statement to your controller:

      import javax.xml._

    0 讨论(0)
提交回复
热议问题