运行Ant脚本时代理问题

时间:2011-02-24 16:41:50

标签: java ant proxy

我正在为我的项目目的开发一个Ant脚本,并发现我的代理会给我带来问题。以下是“复制”任务的Apache文档中最简单的示例:

=================== build.xml =====================
<project default="simplestCopy">
    <property name="test.dir" value="${basedir}/test/" />

    <target name="simplestCopy">
        <mkdir dir="${test.dir}" />
        <copy todir="${test.dir}" flatten="true">
            <resources>
                <url url="http://ant.apache.org/index.html"/>
            </resources>
        </copy>
    </target>
</project>

我有下一个错误:

d:\temp>ant
Buildfile: d:\temp\build.xml

simplestCopy:
java.net.ConnectException: Connection refused: connect

BUILD FAILED
d:\temp\build.xml:7: Warning: Could not find resource url "http://ant.apache.org/index.html" to copy.

我试过设置

<property name="java.net.useSystemProxies" value="true" />

在命令行中定义此属性

d:\temp>ant -Djava.net.useSystemProxies=true -verbose

但得到同样的错误:

d:\temp>ant -Djava.net.useSystemProxies=true -verbose
Apache Ant version 1.8.1 compiled on April 30 2010
Trying the default build file: build.xml
Buildfile: d:\temp\build.xml
Detected Java version: 1.6 in: c:\ProgramFiles\Java\jdk1.6.0_24\jre
Detected OS: Windows XP
parsing buildfile d:\temp\build.xml with URI = file:/d:/temp/build.xml
Project base dir set to: d:\temp
parsing buildfile jar:file:/C:/ProgramFiles/Java/apache-ant-1.8.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/ProgramFiles/Java/apache-ant-1.8.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Build sequence for target(s) `simplestCopy' is [simplestCopy]
Complete build sequence is [simplestCopy, ]

simplestCopy:
    [mkdir] Skipping d:\temp\test because it already exists.
java.net.ConnectException: Connection refused: connect

BUILD FAILED
d:\temp\build.xml:7: Warning: Could not find resource url "http://ant.apache.org/index.html" to copy.
        at org.apache.tools.ant.taskdefs.Copy.execute(Copy.java:487)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
        at org.apache.tools.ant.Main.runBuild(Main.java:801)
        at org.apache.tools.ant.Main.startAnt(Main.java:218)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 1 second

任何想法如何解决?
谢谢你的帮助...

2 个答案:

答案 0 :(得分:4)

答案 1 :(得分:-2)

我启动了tomcat服务器,然后发出命令,它可以正常工作