一、資源準備spring-framework,commons-logging:http://pan.baidu.com/s/1hqxZyfihtml
二、新建Java Application,導入所需jar包,並創建java path。java
三、總體目錄結構以下spring
四、注意config.xml在src下(若是使用FileSystemXmlApplicationContext("config.xml"),則)。不然會報以下錯誤:spa
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [Beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [Beans.xml] cannot be opened because it does not exist調試
五、代碼:xml
5-一、HelloWorld.javahtm
5-二、TMain.java資源
5-三、配置文件config.xml (文件名沒有要求)get
六、運行結果博客
七、注意事項
7-一、第一次調試的時候,會常常遇到找不到class的exception,這是確實相應的jar包,找到相應的jar包,導入進去便可
7-二、config.xml的編寫要特別注意beans的聲明,不然運行的時候,會報beans未定義的錯誤。
7-三、要特別注意調試的報錯,根據報錯到網上查找緣由和解決方法。