首页 > 解决方案 > 在 maven-compiler-plugin 上将 Maven 从 Java 9 迁移到 Java 10 失败

问题描述

尝试将 Maven 从 Java 9 迁移到 Java 10 会在 pom.xml 中产生错误, maven-compiler-plugin但不起作用:

Java 9配置(效果非常好):

<plugin>                                               
    <groupId>org.apache.maven.plugins</groupId>        
    <artifactId>maven-compiler-plugin</artifactId>     
    <version>3.7.0</version>                           
    <configuration>                                    
        <source>1.9</source>                           
        <target>1.9</target>                           
        <release>9</release>                           
        <executable>javac9</executable>                
        <encoding>UTF-8</encoding>                     
    </configuration>                                   
</plugin>     

基于stackoverflow 问题的Java 10配置(失败):

<plugin>                                                                   
    <groupId>org.apache.maven.plugins</groupId>                            
    <artifactId>maven-compiler-plugin</artifactId>                         
    <version>3.7.0</version>                                               
    <configuration>                                                        
        <source>10</source>                                                
        <target>10</target>                                                
        <release>10</release>                                              
        <executable>javac10</executable>                                   
        <encoding>UTF-8</encoding>                                         
    </configuration>                                                       
    <dependencies>                                                         
        <dependency>                                                       
            <groupId>org.ow2.asm</groupId>                                 
            <artifactId>asm</artifactId>                                   
            <version>6.1.1</version> <!-- Use newer version of ASM -->     
        </dependency>                                                      
    </dependencies>                                                        
</plugin>   

错误mvn clean package

[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ XR3Player ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 164 source files to D:\GitHub\XR3Player\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.915 s
[INFO] Finished at: 2018-04-24T18:12:17+03:00
[INFO] Final Memory: 14M/48M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project XR3Player: Fatal error compiling: release version 10 not supported -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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/MojoExecutionException 

标签: javamaven

解决方案


推荐阅读