我正在嘗試遵循this Ant guide,並且我在嘗試添加log4j外部庫的部分出現錯誤。根據指南的說明,我已經下載了相應的this log4j jar並將其放入我的lib庫中。我也試過把jar文件直接解壓到lib文件夾中。Ant無法檢測到外部庫?
錯誤是,雖然我已經導入了必要的庫,並指出Ant在我的build.xml中,但無法找到它。
error: package org.apache.log4j does not exist ...
error: could not find symbol BasicConfigurator.configure(); ...
^
這裏是我的build.xml文件,這是相當多的拷貝,並從例如粘貼(減去 「oata」 包名:
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<property name="main-class" value="HelloWorld"/>
<property name="lib.dir" value="lib"/>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}" classpathref="classpath">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<classpath>
<path refid="classpath"/>
<path location="${jar.dir}/${ant.project.name}.jar"/>
</classpath>
</java>
</target>
<target name="clean-build" depends="clean,jar"/>
<target name="main" depends="clean,run"/>
檢查這是否適用於您http://stackoverflow.com/a/22284104/2549021 – AKS 2014-03-09 16:56:35