栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

springboot maven-compiler-plugin使用

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

springboot maven-compiler-plugin使用


springboot maven-compiler-plugin使用

                           

官网:Apache Maven Compiler Plugin – Introduction

                         

                         

********************

maven compiler plugin

                             

The Compiler Plugin is used to compile the sources of your project. 
# compiler创建用来编译项目源码

Since 3.0, the default compiler is javax.tools.JavaCompiler (if you are using java 1.6) 
and is used to compile Java sources. 
# 从3.0版本开始,maven默认使用javax.tools.JavaCompiler编译项目

If you want to force the plugin using javac, you must configure the plugin option
forceJavacCompilerUse.
# 如果要使用jdk提供的javac进行编译,可以用参数forceJavacCompilerUse

Also note that at present the default source setting is 1.6 and the default target setting 
is 1.6, independently of the JDK you run Maven with
# 编译项目source、target都是1.6版本,和运行maven时使用的jdk版本无关

                         

compiler goal

# compiler:compile 
is bound to the compile phase and is used to compile the main source files
# 和compile阶段绑定,用来编译main source文件

# compiler:testCompile 
is bound to the test-compile phase and is used to compile the test source files
# 和test-compile绑定,用来编译test source文件

                            

相关命令

mvn compile:编译main source文件
mvn test-compile:编译test source文件

                    

                                   

********************

插件配置

****************                 

指定编译版本

                            

设置source、target

    
        hello
        

            ...

            
                org.apache.maven.plugins
                maven-compiler-plugin
                3.8.1
                
                    16
                    16
                
            
        
    

 实际运行时不一定会使用指定的版本,可指定对应版本的javac路径,fork设置为true

                   

****************   

使用javac编译

                    

    
        hello
        

            ...

            
                org.apache.maven.plugins
                maven-compiler-plugin
                3.8.1
                
                    true

                    
                    true

                    
                    ${java.home}binjavac
                
            
        
    

                       

****************   

设置编译内存

                    

    
        hello
        

            ...

            
                org.apache.maven.plugins
                maven-compiler-plugin
                3.8.1
                
                    true
                    16
                    16
                    true
                    ${java.home}binjavac

                    
                    100m
                    200m
                
            
        
    

                              

****************   

设置编译参数

                    

    
        hello
        

            ...

            
                org.apache.maven.plugins
                maven-compiler-plugin
                3.8.1
                
                    16
                    16
                    true
                    ${java.home}binjavac
                    100m
                    200m

                    
                    
                        -verbose
                        -Xlint:all,-options,-path
                    
                
            
        
    

                            

                 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/287053.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号