Groovy + Java 混合编程方案:GMaven

Groovy + Java 混合编程方案:GMaven

Hava a look

先看效果。在项目中随便创建一个 SayHiUtil.groovy,然后在main里面添加个执行打印一下

package com.cmb.lr20.zxb.dialog.utils

class SayHIUtil {

    static def sayHi() {
        println "Hi groovy"
    }
}
public class DialogApplication {

    public static void main(String[] args) {
        SayHIUtil.sayHi();
        SpringApplication.run(DialogApplication.class, args);
    }
}

Groovy + Java 混合编程方案:GMaven_第1张图片

DO IT!

使用GMavenPlus,只需加个 plugin 和 dependency 即可:

    

    
        
        
            org.codehaus.groovy
            groovy
            3.0.9
        
    


    
        
            org.codehaus.gmavenplus
            gmavenplus-plugin
            1.13.1
            
                
                    
                        addSources
                        addTestSources
                        generateStubs
                        compile
                        generateTestStubs
                        compileTests
                        removeStubs
                        removeTestStubs
                    
                
            
        
        
            
            org.apache.maven.plugins
            maven-source-plugin
            
            3.2.1
            
                
                    attach-sources
                    
                        jar-no-fork
                        test-jar-no-fork
                    
                
            
        
    

你可能感兴趣的:(Groovy + Java 混合编程方案:GMaven)