1、ant安裝、配置后報錯:Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/Launcher : Unsupported major.minor version 52.0 ……
解決方案:ant下載最新版本1.10.1應該是1.8版本java編譯生成。降低重新下載ant 1.7.1版本,執行ant命令,運行正常。

2、ANT編譯錯誤: 編碼utf8的不可映射字符
解決方案:
使用eclispse的JDK進行編譯。修改build.xml文件,加上如下屬性:
<project basedir="." default="antwar_fjwan" name="carzone_ds">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
同時javac添加jdk版本參數
<javac nowarn="on" srcdir="${basedir}\src" destdir="${basedir}\WebContent\WEB-INF\classes" encoding="utf-8" source="1.7" target="1.7" includeantruntime="false">
ant一下,會報找不到org.eclipse.jdt.core.JDTCompilerAdapter
將eclipse/plugins目錄下把org.eclipse.jdt.*文件拷到ant/lib目錄下。以及org.eclispe.jdt.core_…….jar里面的jdtCompilerAdapter.jar拷到ant/lib目錄下。然后重新編譯,一切OK。

3、在上一個問題中我的jdtCompilerAdapter.jar是從網上直接下載的,編譯時有些文件會提示編譯錯誤:Cannot switch on a value of type String. Only convertible int values or enum constants are permitted。
解決方案:由於Ant編譯時的JDK版本為1.6,但是現在應該使用1.7編譯導致的。將eclips/plugins目錄下org.eclispe.jdt.core_…….jar解壓取里面的jdtCompilerAdapter.jar拷到ant/lib目錄下。然后重新編譯,一切OK。

