Eclipse報錯"No embedded stylesheet instruction for file"的解決方法
原文:https://hi.baidu.com/ini_always/blog/item/3c4b7a531ca15e15377abe7e.html
前一陣子去實習,後來也沒什麼好寫的,所以很久沒寫東西了。今天剛好遇到個錯誤,而且是可寫的,所以拿來和大家一起分享。
先看一下控製台輸出的內容,如下:
15:34:18,286 INFO [main] Main - javax.xml.transform.TransformerFactory=null 15:34:18,288 INFO [main] Main - java.endorsed.dirs=C:\SDKs\JDK\jre\lib\endorsed 15:34:18,293 INFO [main] Main - launchFile: E:\Eclipse Works\.metadata\.plugins\org.eclipse.wst.xsl.jaxp.launching\launch\launch.xml 15:34:18,351 FATAL [main] Main - No embedded stylesheet instruction for file: file:/E:/Eclipse%20Works/filemanager2.x/config/conf.xml org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file: file:/E:/Eclipse%20Works/filemanager2.x/config/conf.xml at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:225) at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:186) at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.Main.main(Main.java:73) Caused by: org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file: file:/E:/Eclipse%20Works/filemanager2.x/config/conf.xml at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:214) ... 2 more
以上錯誤是我在Eclipse中運行程序時,點擊那個綠色的Run按鈕時出現的,於是我Copy了關鍵詞去Google,Google出來的東東邊都沾不上。度娘更不行,看來,隻有自己瞎掰了,說不定能掰出來呢。
我又嚐試在Project上點右鍵,Run As->Java Application,結果居然能運行,我了個去,莫非是Eclipse的Bug?突然我靈光一閃,因為我點擊Run按鈕時,編輯界麵顯示的是一個xml文件,莫非?於是點擊Run按鈕右側的下拉列表,選擇main()方法所在的類運行,居然成功了!好了,真相大白了。
分析:因為編輯界麵顯示的是一個xml文件,所以點Run按鈕時,Eclipse並不是去Project中尋找main()方法來運行,而是“運行”當前的xml文件,至於是在幹什麼我也不清楚,結果也很簡單,因為你的xml不符合Eclipse的“運行”要求,所以它自然要報錯了。
解決方法:運行Project時不要把編輯界麵放在xml上,或者,手動選擇main()方法所在的類,點"Run"。
最後更新:2017-04-02 06:51:43