English 中文(简体)
我能否避免在格罗维耶使用格拉佩加装模块?
原标题:Can I avoid using Grape to load modules in Groovy?

I am writing my first automation script in groovy and I ve hit a roadblock. While making use of the AntBuilder class to run sshexec() I run into the following error:

: Problem: failed to create task or type sshexec
Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec was not found.
    This looks like one of Ant s optional components.
Action: Check that the appropriate optional JAR exists in
    -ANT_HOMElib
    -the IDE Ant configuration dialogs

Do not panic, this is a common problem.
The commonest cause is a missing JAR.

This is not a bug; it is a configuration problem

迄今为止,我找到的最佳解决办法是利用这一办法。

Grape.grab(group : "com.jcraft", module : "jsch", classLoader : this.class.classLoader.rootLoader)
Grape.grab(group:"ant", module:"ant-jsch", classLoader:this.class.classLoader.rootLoader)

in order to load the required modules. However, I would like to eliminate the lag time of Grape downloading the jars from the remote Maven repository.

是否有办法下载和节省今后使用的模块,或许可在JAVA_中。 a. 适当或可采用的方法?

最佳回答

Adding the required jars to %ANT_HOME% and %GROOVY_HOME% wasn t working.

解决办法是将jar降至%以下。 groovylib——在此之后,不再需要Grape电话。 希望这对有相同问题的其他人有用。

感谢Dave使我走上正轨。

问题回答

• 利用“格拉佩”说明,在运行时间下载文字依赖:

@Grapes([
    @Grab(group= org.apache.ant , module= ant-jsch , version= 1.8.3 ),
    @GrabConfig(systemClassLoader=true)
])

def ant = new AntBuilder()

ant.sshexec(host:"somehost", username:"yo", password:"dude", command:"ls")

如果你回到防火墙后,你还可以没收贵马文存放处的位置:

@GrabResolver(name="my-repo", root="http://my.hostname/maven/repo")

Final tip, the property groovy.grape.autoDownload can be used to control whether grape does arangedown or only use its castalfile.

groovy -Dgroovy.grape.autoDownload=false myscript.groovy

假设你只剩下两台机器,我会造出一只葡萄树脂,并编造一根 。 违约时间为30天。 这将告诉格拉佩斯,如果你有依赖性,则每30天只能检查更新的附属地的偏远存放处。 详情见





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签