(未解决)
环境:
Java1.7+scala 2.10.6
配置:
创建maven工程,建立如下目录结构:
pom.xml
<?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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>untitled1</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>7</maven.compiler.source> <maven.compiler.target>7</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!-- 导入scala的依赖 --> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>2.10.6</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId> <version>3.2.2</version> <executions> <execution> <id>scala-compile-first</id> <phase>process-resources</phase> <goals> <goal>add-source</goal> <goal>compile</goal> </goals> </execution> <execution> <id>scala-test-compile</id> <phase>process-test-resources</phase> <goals> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
已添加scala环境支持。
报错:
scalac: Error: Error compiling the sbt component 'compiler-interface-2.10.6-61.0' sbt.internal.inc.CompileFailed: Error compiling the sbt component 'compiler-interface-2.10.6-61.0' at sbt.internal.inc.AnalyzingCompiler$.handleCompilationError$1(AnalyzingCompiler.scala:436) at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$5(AnalyzingCompiler.scala:453) at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$5$adapted(AnalyzingCompiler.scala:448) at sbt.io.IO$.withTemporaryDirectory(IO.scala:490) at sbt.io.IO$.withTemporaryDirectory(IO.scala:500) at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$2(AnalyzingCompiler.scala:448) at sbt.internal.inc.AnalyzingCompiler$.$anonfun$compileSources$2$adapted(AnalyzingCompiler.scala:440) at sbt.io.IO$.withTemporaryDirectory(IO.scala:490) at sbt.io.IO$.withTemporaryDirectory(IO.scala:500) at sbt.internal.inc.AnalyzingCompiler$.compileSources(AnalyzingCompiler.scala:440) at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$.org$jetbrains$jps$incremental$scala$local$CompilerFactoryImpl$$getOrCompileInterfaceJar(CompilerFactoryImpl.scala:164) at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.$anonfun$getScalac$1(CompilerFactoryImpl.scala:58) at scala.Option.map(Option.scala:242) at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.getScalac(CompilerFactoryImpl.scala:51) at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.createCompiler(CompilerFactoryImpl.scala:20) at org.jetbrains.jps.incremental.scala.local.CachingFactory.$anonfun$createCompiler$3(CachingFactory.scala:21) at org.jetbrains.jps.incremental.scala.local.Cache.$anonfun$getOrUpdate$2(Cache.scala:17) at scala.Option.getOrElse(Option.scala:201) at org.jetbrains.jps.incremental.scala.local.Cache.getOrUpdate(Cache.scala:16) at org.jetbrains.jps.incremental.scala.local.CachingFactory.createCompiler(CachingFactory.scala:21) at org.jetbrains.jps.incremental.scala.local.LocalServer.doCompile(LocalServer.scala:38) at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:25) at org.jetbrains.jps.incremental.scala.remote.Main$.compileLogic(Main.scala:197) at org.jetbrains.jps.incremental.scala.remote.Main$.$anonfun$handleCommand$1(Main.scala:184) at org.jetbrains.jps.incremental.scala.remote.Main$.decorated$1(Main.scala:174) at org.jetbrains.jps.incremental.scala.remote.Main$.handleCommand(Main.scala:181) at org.jetbrains.jps.incremental.scala.remote.Main$.serverLogic(Main.scala:157) at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:97) at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala) at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at com.facebook.nailgun.NGSession.runImpl(NGSession.java:312) at com.facebook.nailgun.NGSession.run(NGSession.java:198)
尝试解决方法:
开始时使用java8,报错搜索结果均显示scala与java版本不匹配,遂降低为java7,仍报错。
结果:
放到centos集群上运行就能跑了,集群的java和scala版本跟windows下一模一样。怪事。
希望好心人看到能解答。非常感谢。