我尝试构建包含Scala和Java类的Maven项目:
sudo mvn clean -X install -DskipTests
如何解决这个问题?
[错误]无法执行目标 net.alchim31.maven:斯卡拉,Maven的插件:3.2.0:编译 (scala-compile-first)项目spark-streaming-flume-sink_2.10: 执行scala-compile-first of first net.alchim31.maven:scala-maven-plugin:3.2.0:编译失败。 CompileFailed - > [帮助1] org.apache.maven.lifecycle.LifecycleExecutionException:失败 执行目标net.alchim31.maven:scala-maven-plugin:3.2.0:编译 (scala-compile-first)项目spark-streaming-flume-sink_2.10: 执行scala-compile-first of first net.alchim31.maven:scala-maven-plugin:3.2.0:编译失败。在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) 在 org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 在 org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)at at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)at at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)at org.apache.maven.cli.MavenCli.execute(mavenCli.java:862)at at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)at at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)at at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498)at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 在 org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 在 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 在 org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 引起:org.apache.maven.plugin.PluginExecutionException:执行 scala-compile-first of first net.alchim31.maven:scala-maven-plugin:3.2.0:编译失败。在 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 20更多引起:编译失败 sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:105)at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)at sbt.compiler.AggressiveCompile $$ anonfun $ $$ 3 $ anonfun compileScala $ 1 $ $ 1.适用MCV $ SP(AggressiveCompile.scala:99) 在 sbt.compiler.AggressiveCompile $$ anonfun $ $$ 3 $ anonfun compileScala $ 1 $ 1.适用(AggressiveCompile.scala:99) 在 sbt.compiler.AggressiveCompile $$ anonfun $ $$ 3 $ anonfun compileScala $ 1 $ 1.适用(AggressiveCompile.scala:99) 在 sbt.compiler.AggressiveCompile.sbt $ $编译$$ AggressiveCompile定时(AggressiveCompile.scala:166) 在 sbt.compiler.AggressiveCompile $$ anonfun $ 3.compileScala $ 1(AggressiveCompile.scala:98) 在 sbt.compiler.AggressiveCompile $$ anonfun $ 3.apply(AggressiveCompile.scala:143) 在 sbt.compiler.AggressiveCompile $$ anonfun $ 3.apply(AggressiveCompile.scala:87) 在 sbt.inc.IncrementalCompile $$ anonfun $ doCompile $ 1.适用(Compile.scala:39) 在 sbt.inc.IncrementalCompile $$ anonfun $ doCompile $ 1.适用(Compile.scala:37) 在sbt.inc.IncrementalCommon.cycle(Incremental.scala:99)at sbt.inc.Incremental $$ anonfun $ 1.apply(Incremental.scala:38)at sbt.inc.Incremental $$ anonfun $ 1.apply(Incremental.scala:37)at sbt.inc.Incremental $ .manageClassfiles(Incremental.scala:65)at sbt.inc.Incremental $ .compile(Incremental.scala:37)at sbt.inc.IncrementalCompile $ .apply(Compile.scala:27)at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:157) 在 sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:71) 在com.typesafe.zinc.Compiler.compile(Compiler.scala:184)at com.typesafe.zinc.Compiler.compile(Compiler.scala:164)at sbt_inc.SbtIncrementalCompiler.compile(SbtIncrementalCompiler.java:92) 在 scala_maven.ScalaCompilerSupport.incrementalCompile(ScalaCompilerSupport.java:303) 在 scala_maven.ScalaCompilerSupport.compile(ScalaCompilerSupport.java:119) 在 scala_maven.ScalaCompilerSupport.doExecute(ScalaCompilerSupport.java:99) 在scala_maven.ScalaMojoSupport.execute(ScalaMojoSupport.java:482) 在 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
<build>
pom.xml文件的一部分:
<build> <defaultGoal>package</defaultGoal> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> <resource> <directory>src/test/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>${project.build.sourceEncoding}</encoding> </configuration> <executions> <execution> <goals> <goal>copy-resources</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId> <version>3.2.0</version> <configuration> <!--<recompileMode>incremental</recompileMode>--> <args> <arg>-target:jvm-1.7</arg> </args> <javacArgs> <javacArg>-source</javacArg> <javacArg>1.7</javacArg> <javacArg>-target</javacArg> <javacArg>1.7</javacArg> </javacArgs> </configuration> <executions> <execution> <id>scala-compile</id> <phase>process-resources</phase> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>scala-test-compile</id> <phase>process-test-resources</phase> <goals> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.7</source> <target>1.7</target> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin>
org.eclipse.m2e 生命周期映射 1.0.0 net.alchim31.maven 斯卡拉,Maven的插件 [3.1.6,) 编 testCompile
更新(依赖项部分):
<dependencies>
<dependency>
<groupId>org.apache.flume</groupId>
<artifactId>flume-ng-sdk</artifactId>
<exclusions>
<!-- Guava is excluded to avoid its use in this module. -->
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<!--
Exclude libthrift since the flume poms seem to confuse sbt, which fails to find the
dependency.
-->
<exclusion>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.flume</groupId>
<artifactId>flume-ng-core</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</dependency>
<dependency>
<!-- Add Guava in test scope since flume actually needs it. -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!--
Netty explicitly added in test as it has been excluded from
Flume dependency (to avoid runtime problems when running with
Spark) but unit tests need it. Version of Netty on which
Flume 1.4.0 depends on is "3.4.0.Final" .
-->
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>3.4.0.Final</version>
<scope>test</scope>
</dependency>
</dependencies>