一、资源准备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-三、要特别注意调试的报错,根据报错到网上查找缘由和解决方法。