如何从MuleStudio和Mule Maven Standalone访问类路径资源?

时间:2014-05-14 08:35:57

标签: maven groovy mule mule-studio

如何使用Groovy脚本从src / main / resources访问类路径资源?以下脚本适用于MuleStudio,但在Mule Maven独立版中不起作用。有没有办法编写脚本,它可以从MuleStudio和Mule Maven独立提取正确的资源?

<scripting:component doc:name="Script">
    <scripting:script engine="Groovy"><![CDATA[
        def command = "src/main/resources/shellscript/shellscriptfile.sh"
        def cmd = command.execute()
        cmd.waitFor()]]>
    </scripting:script>
</scripting:component>

1 个答案:

答案 0 :(得分:1)

您应该将命令作为类路径资源加载,而不是尝试构建适用于所有情况的路径:

def command = this.getClass().getResource('/shellscript/shellscriptfile.sh').path
def cmd = command.execute()
cmd.waitFor()