Spring2 所需Jar包 測試

來源:互聯網
上載者:User

在昨天構建的Struts2項目上測試Spring2所需要的Jar包

 

結果
spring-core.jar
    ——>依賴:spring-web.jar

        ——>依賴:spring-context.jar
        ——>依賴:spring-beans.jar
        ——>依賴:commons-logging.jar

 

 

 

開始,單加入spring-core.jar,配置web.xml

 <!-- ××××××××××××××× Spring配置和監聽 Start ××××××××××××××× -->
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/classes/application*.xml</param-value>
 </context-param>
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>
 <!-- ×××××××××××××××× Spring配置和監聽 End ×××××××××××××××× -->

 

運行——

嚴重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

 

解決——

缺少org.springframework.web.*,加入spring-web.jar

 

 

運行——

嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextException
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextException

 

解決——

缺少org.springframework.context.*,加入spring-context.jar

 

 

運行——

嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/springframework/beans/FatalBeanException
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.FatalBeanException

 

解決——

缺少org.springframework.beans.*,加入spring-beans.jar

 

 

運行——

嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory

 

解決——缺少org.apache.commons.logging.*,加入commons-logging.jar

 

 

 

struts.xml加入<constant name="struts.objectFactory" value="spring" />

運行——
2010-3-3 20:53:35 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
嚴重: Dispatcher initialization failed
Unable to load configuration. - [unknown location]
Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
......
2010-3-3 20:53:35 org.apache.catalina.core.StandardContext filterStart
嚴重: Exception starting filter struts2
Unable to load configuration. - [unknown location]
......
Caused by: Unable to load configuration. - [unknown location]
......
Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
......

 

解決——找不到ObjectFactory,加入struts2-spring-plugin-2.1.8.1.jar

 

不是說struts2整合了spring之後,建立類對象會根據spring設定檔裡面的<bean>來配置嗎?
這裡並沒有做<bean>配置,但是一樣訪問成功了......

 

 

慣例PS:

發現文章有錯的請通知我,非常感謝!

來過的朋友請順便踩一腳......^_^

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.