【发布时间】:2020-09-17 10:40:13
【问题描述】:
我正在尝试使用 Maven 作为构建工具并使用 IntelliJ 作为我的 IDE 创建我的第一个“Hello World”Scala 项目。我在运行mvn package 时不断收到以下错误。
Failed to execute goal org.scala-tools:maven-scala-plugin:2.15.2:compile
这是完整的错误: 无法执行目标 org.scala-tools:maven-scala-plugin:2.15.2:compile (default) on project couchbase-test-3: wrap: org.apache.commons.exec.ExecuteException: Process exited with a error: 1(退出值:1)
这是我的 pom.xml 文件。
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>couchbase-test-3</artifactId>
<version>1.0-SNAPSHOT</version>
<inceptionYear>2008</inceptionYear>
<properties>
<scala.version>2.7.0</scala.version>
</properties>
<repositories>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.specs</groupId>
<artifactId>specs</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-target:jvm-1.5</arg>
</args>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<buildcommands>
<buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
</buildcommands>
<additionalProjectnatures>
<projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
</additionalProjectnatures>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
</classpathContainers>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
我使用的 JDK 是 /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home。
我试图运行的代码只是打印出“Hello World!”:
package org.example
/**
* Hello world!
*
*/
object App extends Application {
println( "Hello World!" )
}
任何想法如何解决这个问题?
【问题讨论】:
-
您可能想使用
App而不是Application并将您自己的对象命名为其他名称。 -
您能否发布
Failed to execute goal org.scala-tools:maven-scala-plugin:2.15.2:compile错误的完整堆栈跟踪?它应该指向有问题的特定代码行。 -
@RayanRal 这是完整的错误(我也更新了问题本身):
Failed to execute goal org.scala-tools:maven-scala-plugin:2.15.2:compile (default) on project couchbase-test-3: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1(Exit value: 1) -
你必须使用 scala
2.7.0并且你的 maven scala 插件有-target:jvm-1.5参数。 Scala 2.7.0 不应该与 Java 1.5 兼容。 -
@SašaZejnilović 目标应该是
-target:jvm-1.8吗?
标签: scala maven intellij-idea