Maven测试错误:javac:源版本1.8需要目标版本1.8

迷迭香

如果我运行mvn -e test,则会收到错误消息:

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Skat09 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Skat09 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 6 resources
[INFO] Copying 191 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ Skat09 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 64 source files to /home/buzz-dee/Workspace/skat09/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] javac: source release 1.8 requires target release 1.8

[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.729 s
[INFO] Finished at: 2015-10-02T23:17:02+02:00
[INFO] Final Memory: 10M/298M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project Skat09: Compilation failure
[ERROR] javac: source release 1.8 requires target release 1.8
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project Skat09: Compilation failure
javac: source release 1.8 requires target release 1.8


    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
javac: source release 1.8 requires target release 1.8


    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:911)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 20 more
[ERROR] 
[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/MojoFailureException

这是我的Maven pom.xml

<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.3</version>
    <configuration>
        <rules>
            <requireJavaVersion>
                <version>1.8</version>
            </requireJavaVersion>
        </rules>
      <source>1.8</source>
      <tagret>1.8</tagret>
    </configuration>
  </plugin>
</plugins>

来自的输出mvn -version

Apache Maven 3.3.3 (NON-CANONICAL_2015-07-27T12:38:38_root; 2015-07-27T11:38:38+02:00)
Maven home: /opt/maven
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-jdk/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "4.2.2-1-arch", arch: "amd64", family: "unix"

Java JDK(archlinux-java get)设置:

java-8-jdk

Java编译器版本(javac -version):

javac 1.8.0_60

我还尝试添加:

<verbose>true</verbose>
<fork>true</fork>
<executable>/usr/lib/jvm/java-8-jdk/bin/javac</executable>
<compilerVersion>1.8</compilerVersion>

POM中configuration元素maven-compiler-plugin

上述错误是什么问题,我该如何解决?

乔恩

你打错了:<tagret>1.8</tagret>应该是<target>1.8</target>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Maven:Javac:源版本1.6需要目标版本1.6

想法:javac:源版本1.7需要目标版本1.7

错误:java:javacTask:源发行版8需要目标发行版1.8

java maven-compiler-plugin:3.1,javacTask:源版本1.7需要目标版本1.7

ruby on rails教程第8章测试错误

在更高版本中使用Java 8目标如何覆盖javac 11链接方法?

Laravel 8(版本 8.35.1):目标类不存在

构建VLC时需要NDKv8b或更高版本

Android Studio 2.2。预览1错误:“请使用JDK 8或更高版本”

Netbeans Maven错误:javac:无效的目标版本:1.7

错误此版本的node / NAN / v8需要C ++ 11编译器

Heroku在日志中安装了错误的jdk(8)版本,但在终端中安装了良好的一(11)版本,这导致无效的目标版本:11

Angular 8的Angular材质版本

更改内部版本-Xcode 8

什么是Windows 8的“最终”版本?

什么是Windows 8的“ N”版本?

Java 8的Maven错误

错误:java:javacTask:源发行版1.8需要目标发行版1.8

在Angular 8中创建组件时,如何解决“检测到无效格式版本-预期:[1]找到:[3]”错误?

仅对 Node 8 或更高版本运行 coffeescript 测试

(r + 1 +(r >> 8))>> 8是什么?

在XCode 8中为iOS 8及更高版本构建框架

为什么在iOS 8及更高版本中使用@ 1x图像?

使用 Composer 为 Drupal 8 模块安装 RC1 版本

我使用jdk8,但Spring告诉我我需要jdk5或更高版本

如果使用Windows 8及更高版本,是否需要安装DirectX SDK?

在大於 8 的 Solidity 版本中不再需要 openzeppelin safemath 嗎?

错误:需要杰克才能支持Java 8语言功能。启用Jack或删除sourceCompatibility JavaVersion.VERSION_1_8

Xcode 8单元测试错误:无法确定TEST_HOST的捆绑包标识符