为了账号安全,请及时绑定邮箱和手机立即绑定

编译一直不通过,异常提示如下。有没有大腿知道是怎么回事的啊

[INFO] Error stacktraces are turned on.

[INFO] Scanning for projects...

[INFO]

[INFO] ---------------------< com.maven01:maven01-model >----------------------

[INFO] Building maven01-model 0.0.1-SNAPSHOT

[INFO] --------------------------------[ jar ]---------------------------------

[INFO]

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven01-model ---

[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!

[INFO] skip non existing resourceDirectory C:\Users\梁伟健\Desktop\code\maven01\src\main\resources

[INFO]

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven01-model ---

[INFO] Changes detected - recompiling the module!

[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!

[INFO] Compiling 1 source file to C:\Users\梁伟健\Desktop\code\maven01\target\classes

[INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR :

[INFO] -------------------------------------------------------------

[ERROR] 不再支持源选项 1.5。请使用 1.6 或更高版本。

[ERROR] 不再支持目标选项 1.5。请使用 1.6 或更高版本。

[INFO] 2 errors

[INFO] -------------------------------------------------------------

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1.168 s

[INFO] Finished at: 2018-04-23T18:43:25+08:00

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven01-model: Compilation failure: Compilation failure:

[ERROR] 不再支持源选项 1.5。请使用 1.6 或更高版本。

[ERROR] 不再支持目标选项 1.5。请使用 1.6 或更高版本。

[ERROR] -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven01-model: Compilation failure

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke (Method.java:564)

    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

    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:858)

    at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:129)

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke (Method.java:564)

    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)

[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


正在回答

2 回答

后来我网上找了资料解决了(我觉得是maven默认配置的jdk版本太低了,具体原因不清楚,欢迎补充),主要有2种解决方法:

1.在pom.xml了添加下面代码

  <properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<maven.compiler.source>1.8</maven.compiler.source>

<maven.compiler.target>1.8</maven.compiler.target>

    </properties>

2.修改全局配置文件,一劳永逸,修改maven目录-->conf目录-->settings.xml文件。找到<profiles>标签,在里面添加新的jdk:

<profile>  

     <id>jdk-1.8</id>  

     <activation>  

         <activeByDefault>true</activeByDefault>  

         <jdk>1.8</jdk>  

     </activation>

     <properties>  

         <maven.compiler.source>1.8</maven.compiler.source>  

         <maven.compiler.target>1.8</maven.compiler.target>  

         <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>  

     </properties>   

</profile>  

2 回复 有任何疑惑可以回复我~

是不是JDK版本不对,试过修改JDK版本吗?

0 回复 有任何疑惑可以回复我~
#1

极客小健 提问者

我已经解决了,应该是配置里面的jdk版本不对。Thanks♪(・ω・)ノ
2018-04-23 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
项目管理利器——maven
  • 参与学习       173090    人
  • 解答问题       742    个

使用maven来构建和管理Java项目,从环境配置,到maven核心知识

进入课程

编译一直不通过,异常提示如下。有没有大腿知道是怎么回事的啊

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信