解決路徑:
依據報錯資訊提示:找到 元素"*B"檢視該元素下的”*A“屬性存在的異常,一般都是格式問題。因為是xml檔案,可以考慮将檔案用NotPad++、dreamweaver等工具打開,檔案的格式資訊會有所展現,仔細檢視,就能發現問題。(會有一種感覺,沒有什麼大不了。。。。工具是神奇的!!!)
常見問題:
D:\>ant
Buildfile: build.xml
BUILD FAILED
D:\build.xml:4: Open quote is expected for attribute "file" associated with an element type "copy".
Total time: 2 seconds
D:\>ant
Buildfile: build.xml
BUILD FAILED
D:\build.xml:4: Open quote is expected for attribute "overwrite" associated with an element type "copy".
Total time: 0 seconds
build.xml内容:
// 【改前】簡單示例
<?xml version="1.0" encoding="GBK"?>
<project name="測試腳本" default="copyfile" basedir=".">
<target name="copyfile">
<copy file="d:/BugReport.txt" todir="c:/temp" overwrite="true"/>
</target>
</project>
解決方案:
将copy中的雙引号(")換成單引号(')
修改後的build.xml内容:
// 【改後】簡單示例
<?xml version="1.0" encoding="GBK"?>
<project name="測試腳本" default="copyfile" basedir=".">
<target name="copyfile">
<copy file='d:/BugReport.txt' todir='c:/temp' overwrite='true'/>
</target>
</project>
執行結果(成功!):
D:\>ant
Buildfile: build.xml
copyfile:
[copy] Copying 1 file to C:\temp
BUILD SUCCESSFUL
Total time: 1 second
D:\>ant
Buildfile: build.xml
copyfile:
[copy] Copying 1 file to C:\temp
BUILD SUCCESSFUL
Total time: 0 seconds
D:\>
這都是我們喜歡看到的!!!