最好是全部導入,只導入5個可能不行(我就失敗了一次)
2.在Eclipse中創建一個User Libraries,並將剛纔的所有包導入進來
windows->preferences->java->build Path->User Liberaries->new
然後寫個名字就可以。
點擊add External Jars
(可以先把包放入WebContent/WEB-INF/lib下)
3.新建項目文件,具體請參考此鏈接
http://jingyan.baidu.com/album/e52e36154d0cf040c70c516e.html?picindex=12
4.applicationContext.xml配置文件及其代碼
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="helloworld" class="com.yxx.HelloWorld">
<property name="name" value="Spring_Helloworld"/>
</bean>
</beans>
*********************************************************
5.The processing instruction target matching "[xX][mM][lL]" is not allowed.
如果出現此種異常
1.去掉最前面的空格
6.如果出現類型轉換錯誤之類的可以看看是否是包加錯了
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
配置文件的源文件與鏈接中的路徑不一樣,請注意