How do you access a class path resource from src/main/resources with a Groovy script? The following script works in MuleStudio, but does not work in Mule Maven standalone. Is there a way to write the script where it can pull the correct resource from MuleStudio and Mule Maven standalone?

<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>
有帮助吗?

解决方案

You should load the command as a classpath resource instead of trying to build a path that works in all cases:

def command = this.getClass().getResource('/shellscript/shellscriptfile.sh').path
def cmd = command.execute()
cmd.waitFor()
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top