首页 > 解决方案 > 无法为 GROOVY 脚本解析类 org.ajoberstar.grgit.Grgit

问题描述

我试图运行下面的代码片段,但它返回了上面的异常

import org.ajoberstar.grgit.Grgit
import org.ajoberstar.grgit.Credentials

def grgit = Grgit.clone(dir: 'path/to/dir', url: 'git/uri/here')

grgit.close()

任何可能的解决方案?

标签: mule

解决方案


此流程有效:

 <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <flow name="util-testFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/clone" doc:name="HTTP"/>
        <scripting:component doc:name="Groovy">
            <scripting:script engine="Groovy"><![CDATA[import org.ajoberstar.grgit.Grgit
import org.ajoberstar.grgit.Credentials

def grgit = Grgit.clone(dir: 'test', uri: 'https://github.com/rmccue/test-repository.git')

grgit.close()]]></scripting:script>
        </scripting:component>
    </flow>

只要您的 pom.xml 中有以下内容:

<!-- https://mvnrepository.com/artifact/org.ajoberstar/grgit -->
<dependency>
  <groupId>org.ajoberstar</groupId>
  <artifactId>grgit</artifactId>
  <version>1.7.0</version>
</dependency>

推荐阅读